PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/unclassified/aux_generic6ll.e

http://github.com/tybor/Liberty
Specman e | 140 lines | 84 code | 22 blank | 34 comment | 1 complexity | 2a47b969347a9f8feb9b3f18c4380116 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_GENERIC6LL[G]
  5   --insert
  6   --      ANY
  7
  8create {ANY}
  9   make
 10
 11feature {ANY}
 12   make
 13      do
 14         create rep.make(1, 20)
 15         count := 0
 16         index := 0
 17      end
 18
 19feature {ANY}
 20   empty: BOOLEAN
 21      do
 22         Result := count = 0
 23      end
 24
 25   count: INTEGER
 26
 27   i_th (i: INTEGER): G
 28      require
 29         i >= 1
 30         i <= count
 31      do
 32         Result := rep.item(i)
 33      end
 34
 35   item: G
 36      do
 37         Result := rep.item(index)
 38      end
 39
 40   forth
 41      do
 42         index := index + 1
 43      end
 44
 45   put (x: G)
 46      require
 47         not_of: not off
 48      do
 49         rep.put(x, count)
 50      end
 51
 52   extend (x: G)
 53      do
 54         count := count + 1
 55         if count > rep.upper then
 56            rep.resize(1, count + 10)
 57         end
 58         -- if
 59         rep.put(x, count)
 60      end
 61
 62   after: BOOLEAN
 63      do
 64         Result := index > count
 65      end
 66
 67   off: BOOLEAN
 68      do
 69         Result := index < 1 or index > count
 70      end
 71
 72   start
 73      do
 74         index := 1
 75      end
 76
 77   has (x: G): BOOLEAN
 78      do
 79         Result := rep.first_index_of(x) <= count
 80      end
 81
 82   first: G
 83      do
 84         Result := rep.item(1)
 85      end
 86
 87   last: G
 88      do
 89         Result := rep.item(count)
 90      end
 91
 92   remove_last
 93      require
 94         not empty
 95      do
 96         count := count - 1
 97      end
 98
 99   wipe_out
100      do
101         count := 0
102      end
103
104   index: INTEGER
105
106feature {ANY}
107   -- acc�s au curseur
108   --    cursor : CURSOR
109   --   do
110   --       !!Result.make(index);
111   --   end; -- cursor
112   --
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_GENERIC6LL
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-- ------------------------------------------------------------------------------------------------------------------------------