home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / link2.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  76 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. class LINK2[E]
  13.    --
  14.    -- To implement TWO_WAY_LINKED_LIST[E].
  15.    --
  16.  
  17. creation {LINK2_LIST,TWO_WAY_LINKED_LIST} make
  18.  
  19. feature {LINK2_LIST,TWO_WAY_LINKED_LIST,LINK2}
  20.    
  21.    item: E;
  22.  
  23.    previous, next: like Current;
  24.  
  25. feature {LINK2_LIST,TWO_WAY_LINKED_LIST}
  26.    
  27.    make(i: like item; p: like previous; n: like next) is
  28.       do
  29.          item := i;
  30.          previous := p;
  31.          next := n;
  32.       ensure
  33.          item = i;
  34.          previous = p;
  35.          next = n
  36.       end;
  37.    
  38. feature {LINK2_LIST,TWO_WAY_LINKED_LIST,LINK2}
  39.  
  40.    set_item(i: like item) is
  41.       do
  42.          item := i;
  43.       ensure
  44.          item = i
  45.       end;
  46.  
  47.    set_next(n: like next) is
  48.       do
  49.          next := n;
  50.       ensure
  51.          next = n
  52.       end;
  53.  
  54.    set_all_with(v: like item) is
  55.       local
  56.          lnk: like Current;
  57.       do
  58.          from
  59.             lnk := Current;
  60.          until
  61.             lnk = Void
  62.          loop
  63.             lnk.set_item(v);
  64.             lnk := lnk.next;
  65.          end;
  66.       end;
  67.  
  68.    set_previous(p: like previous) is
  69.       do
  70.          previous := p;
  71.       ensure
  72.          previous = p
  73.       end;
  74.  
  75. end -- LINK2[E]
  76.