home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / link.e < prev    next >
Text File  |  1999-06-05  |  2KB  |  67 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 LINK[E]
  13.    --
  14.    -- To implement LINKED_LIST[E].
  15.    --
  16.  
  17. creation {LINK_LIST,LINKED_LIST} make
  18.  
  19. feature {LINK,LINK_LIST,LINKED_LIST}
  20.    
  21.    item: E;
  22.  
  23.    next: like Current;
  24.  
  25. feature {LINK_LIST,LINKED_LIST}
  26.  
  27.    make(i: like item; n: like next) is
  28.       do
  29.          item := i;
  30.          next := n;
  31.       ensure
  32.          item = i;
  33.          next = n
  34.       end;
  35.    
  36. feature {LINK,LINK_LIST,LINKED_LIST}
  37.  
  38.    set_item(i: like item) is
  39.       do
  40.          item := i;
  41.       ensure
  42.          item = i
  43.       end;
  44.  
  45.    set_next(n: like next) is
  46.       do
  47.          next := n;
  48.       ensure
  49.          next = n
  50.       end;
  51.  
  52.    set_all_with(v: like item) is
  53.       local
  54.          lnk: like Current;
  55.       do
  56.          from
  57.             lnk := Current;
  58.          until
  59.             lnk = Void
  60.          loop
  61.             lnk.set_item(v);
  62.             lnk := lnk.next;
  63.          end;
  64.       end;
  65.  
  66. end -- LINK[E]
  67.