PageRenderTime 10ms CodeModel.GetById 7ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/unclassified/aux_generic7ll.e

http://github.com/tybor/Liberty
Specman e | 140 lines | 86 code | 23 blank | 31 comment | 1 complexity | ab7e063c70a880e9437e852a43878efb MD5 | raw file
  1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2-- See the Copyright notice at the end of this file.
  3--
  4class AUX_GENERIC7LL[G]
  5
  6insert
  7   ANY
  8
  9create {ANY}
 10   make
 11
 12feature {ANY}
 13   make
 14      do
 15         create rep.make(1, 20)
 16         count := 0
 17         index := 0
 18      end
 19
 20feature {ANY}
 21   empty: BOOLEAN
 22      do
 23         Result := count = 0
 24      end
 25
 26   count: INTEGER
 27
 28   i_th (i: INTEGER): G
 29      require
 30         i >= 1
 31         i <= count
 32      do
 33         Result := rep.item(i)
 34      end
 35
 36   item: G
 37      do
 38         Result := rep.item(index)
 39      end
 40
 41   forth
 42      do
 43         index := index + 1
 44      end
 45
 46   put (x: G)
 47      require
 48         not_of: not off
 49      do
 50         rep.put(x, count)
 51      end
 52
 53   extend (x: G)
 54      do
 55         count := count + 1
 56         if count > rep.upper then
 57            rep.resize(1, count + 10)
 58         end
 59         -- if
 60         rep.put(x, count)
 61      end
 62
 63   after: BOOLEAN
 64      do
 65         Result := index > count
 66      end
 67
 68   off: BOOLEAN
 69      do
 70         Result := index < 1 or index > count
 71      end
 72
 73   start
 74      do
 75         index := 1
 76      end
 77
 78   has (x: G): BOOLEAN
 79      do
 80         Result := rep.first_index_of(x) <= count
 81      end
 82
 83   first: G
 84      do
 85         Result := rep.item(1)
 86      end
 87
 88   last: G
 89      do
 90         Result := rep.item(count)
 91      end
 92
 93   remove_last
 94      require
 95         not empty
 96      do
 97         count := count - 1
 98      end
 99
100   wipe_out
101      do
102         count := 0
103      end
104
105   index: INTEGER
106
107feature {ANY}
108   -- acc�s au curseur
109   --    cursor : CURSOR
110   --   do
111   --       !!Result.make(index);
112   --   end; -- cursor
113   --    go_to (c: CURSOR)
114   --   do
115   --       index := c.value;
116   --   end; -- go_to
117   
118
119feature {}
120   rep: ARRAY[G]
121
122end -- class AUX_GENERIC7LL
123--
124-- ------------------------------------------------------------------------------------------------------------------------------
125-- Copyright notice below. Please read.
126--
127-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
128-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
129-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
130-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
131-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
132-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
133--
134-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
135-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
136--
137-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
138--
139-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
140-- ------------------------------------------------------------------------------------------------------------------------------