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