/test/language/unclassified/diable/aux_diable4.e

http://github.com/tybor/Liberty · Specman e · 104 lines · 66 code · 12 blank · 26 comment · 1 complexity · 0755fa56df03be282955f558d6f2ff04 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_DIABLE4[E]
  5. create {ANY}
  6. from_model
  7. feature {ANY}
  8. from_model (model: COLLECTION[COLLECTION[E]])
  9. -- The `model' is used to fill line by line the COLLECTION2.
  10. -- Assume all sub-collections of `model' have the same indexing.
  11. local
  12. line, column: INTEGER
  13. do
  14. make(model.lower, model.upper, model.first.lower, model.first.upper)
  15. from
  16. line := model.lower
  17. until
  18. line > model.upper
  19. loop
  20. from
  21. column := model.first.lower
  22. until
  23. column > model.first.upper
  24. loop
  25. put(model.item(line).item(column), line, column)
  26. column := column + 1
  27. end
  28. line := line + 1
  29. end
  30. end
  31. put (element: like item; line, column: INTEGER)
  32. do
  33. storage.put(element, (line - lower1) * count2 + column - lower2)
  34. end
  35. item (line, column: INTEGER): E
  36. do
  37. Result := storage.item((line - lower1) * count2 + column - lower2)
  38. end
  39. storage: NATIVE_ARRAY[E]
  40. feature {ANY}
  41. lower1, lower2, upper1, upper2: INTEGER
  42. count2: INTEGER
  43. do
  44. Result := upper2 - lower2 + 1
  45. end
  46. make (line_min, line_max, column_min, column_max: INTEGER)
  47. -- Reset all bounds `line_minimum' / `line_maximum' / `column_minimum' and
  48. -- `column_maximum' using arguments as new values.
  49. -- All elements are set to the default value of type E.
  50. require
  51. line_min <= line_max
  52. column_min <= column_max
  53. do
  54. lower1 := line_min
  55. upper1 := line_max
  56. lower2 := column_min
  57. upper2 := column_max
  58. if capacity >= count then
  59. storage.clear_all(count - 1)
  60. else
  61. capacity := count
  62. storage := storage.calloc(count)
  63. end
  64. end
  65. capacity: INTEGER
  66. count: INTEGER
  67. do
  68. Result := count1 * count2
  69. end
  70. count1: INTEGER
  71. do
  72. Result := upper1 - lower1 + 1
  73. end
  74. end -- class AUX_DIABLE4
  75. --
  76. -- ------------------------------------------------------------------------------------------------------------------------------
  77. -- Copyright notice below. Please read.
  78. --
  79. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  80. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  81. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  82. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  83. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  84. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  85. --
  86. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  87. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  88. --
  89. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  90. --
  91. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  92. -- ------------------------------------------------------------------------------------------------------------------------------