///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Library                                //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name    := LINKED2_LIST_NODE[V];


  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";

  - comment := "To implement LINKED2_LIST[V].";
    
Section Inherit
  
  - parent_any_two_way_linked_list_node:ANY_TWO_WAY_LINKED_LIST_NODE := ANY_TWO_WAY_LINKED_LIST_NODE;
  
Section Public
  
  + item:V;
  
  + previous:LINKED2_LIST_NODE[V];
  
  + next:LINKED2_LIST_NODE[V];

Section LINKED2_LIST
  
  - create i:V previous p:SELF next n:SELF :SELF<-
  ( + result:SELF;
    
    result := clone;
    result.make i previous p next n;
    result
  );
    
  - make i:V previous p:SELF next n:SELF <-
  (
    item := i;
    previous := p;
    next := n;
  )
  [
    +? {item = i};
    +? {previous = p};
    +? {next = n};
  ];

Section LINKED2_LIST,LINKED2_LIST_NODE
  
  - set_item i:V <-
  (
    item := i;
  )
  [
    +? {item = i};
  ];
    
  - set_next n:SELF <-
  (
    next := n;
  )
  [
    +? {next = n};
  ];
  
  - set_all_with v:V <-
  ( + lnk:SELF;
    
    lnk := Self;    
    {lnk = NULL}.until_do {
      lnk.set_item v;
      lnk := lnk.next;
    };
  );
    
  - set_previous p:SELF <-
  (
    previous := p;
  )
  [
    +? {previous = p};
  ];
