PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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