home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel 68k / lib_test / aux_generic7ll.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  1.7 KB  |  124 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class AUX_GENERIC7LL[G]
  5.  
  6. creation make
  7.  
  8. feature
  9.  
  10.     make is
  11.     do
  12.         !!rep.make(1, 20);
  13.         count := 0;
  14.         index := 0;
  15.     end; -- make
  16.  
  17. feature 
  18.  
  19.     empty: BOOLEAN is
  20.     do
  21.         Result := (count = 0);
  22.     end; -- empty
  23.  
  24.     count: INTEGER;
  25.  
  26.     i_th (i: INTEGER): G is
  27.     require
  28.         i >= 1;
  29.         i <= count;
  30.     do
  31.         Result := rep.item(i);
  32.     end; -- i_th
  33.  
  34.     item: G is
  35.     do
  36.         Result := rep.item(index);
  37.     end; -- item;
  38.  
  39.     forth is
  40.     do
  41.         index := index + 1;
  42.     end; -- forth
  43.  
  44.     put (x: G) is
  45.     require
  46.         not_of: not off;
  47.     do
  48.         rep.put(x, count);
  49.     end; -- put
  50.  
  51.     extend (x: G) is
  52.     do
  53.         count := count + 1;
  54.         if count > rep.upper then
  55.         rep.resize(1, count+10);
  56.         end; -- if
  57.         rep.put(x, count);
  58.     end; -- extend
  59.  
  60.  
  61.     after: BOOLEAN is
  62.     do
  63.         Result := (index > count);
  64.     end; -- after;
  65.  
  66.     off: BOOLEAN is
  67.     do
  68.         Result := (index < 1) or (index > count);
  69.     end; -- off
  70.  
  71.     start is
  72.     do
  73.         index := 1;
  74.     end; -- start
  75.  
  76.     has (x: G): BOOLEAN is
  77.     do
  78.         Result := (rep.index_of(x) <= count);
  79.     end; -- has
  80.  
  81.     first: G is
  82.     do
  83.         Result := rep.item(1);
  84.     end; -- first
  85.  
  86.     last: G is
  87.     do
  88.         Result := rep.item(count);
  89.     end; -- last
  90.  
  91.     remove_last is
  92.     require
  93.         not empty;
  94.     do
  95.         count := count - 1;
  96.     end; -- remove_last
  97.  
  98.     wipe_out is
  99.     do
  100.         count := 0;
  101.     end; -- wipe_out
  102.  
  103.     index: INTEGER;
  104.  
  105.  
  106. feature  -- accĂ‹s au curseur
  107.  
  108.     cursor : CURSOR is
  109.     do
  110.         !!Result.make(index);
  111.     end; -- cursor
  112.  
  113.     go_to (c: CURSOR) is
  114.     do
  115.         index := c.value;
  116.     end; -- go_to
  117.  
  118.  
  119. feature {NONE}
  120.  
  121.     rep: ARRAY[G];
  122.  
  123. end  -- AUX_GENERIC7LL
  124.