+
Point of view
All features
class ARRAY2 [E_]
Summary
General purpose, resizable, two dimensional array.
Direct parents
Inherit list: COLLECTION2
Insert list: NATIVE_ARRAY_COLLECTOR
Class invariant
Overview
Creation features
{ANY}
Features
{ANY}
{ARRAY2}
Creation / modification:
{ANY}
Resizing:
{ANY}
Implementation of others feature from COLLECTION2:
{ANY}
Looking and comparison:
{ANY}
Only for ARRAY2:
{ANY}
Garbage collector tuning (very low-level):
{}
  • mark_native_arrays
    For performance reasons, the unused area of storage is always left as it is when some elements are removed.
Implement manifest generic creation (very low-level):
{}
Indexing:
{ANY}
Index validity:
{ANY}
Counting:
{ANY}
{ANY}
Looking and comparison:
{ANY}
Printing:
{ANY}
Miscellaneous features:
{ANY}
Implement manifest generic creation:
{}
{ANY}
  • test (e1: E_, e2: E_): BOOLEAN
    In order to avoid run-time type errors, feature safe_equal calls is_equal only when e1 and e2 have exactly the same dynamic type.
  • safe_equal (e1: E_, e2: E_): BOOLEAN
    In order to avoid run-time type errors, feature safe_equal calls is_equal only when e1 and e2 have exactly the same dynamic type.
{}
lower1: INTEGER_32
writable attribute
{ANY}
Lower index bounds.
lower2: INTEGER_32
writable attribute
{ANY}
Lower index bounds.
upper1: INTEGER_32
writable attribute
{ANY}
Upper index bounds.
upper2: INTEGER_32
writable attribute
{ANY}
Upper index bounds.
storage: NATIVE_ARRAY[E_]
writable attribute
To store elements line by line.
capacity: INTEGER_32
writable attribute
Number of elements in storage.
set_limits (line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
set lower1,2 and upper1,2 to the given values and alloc storage if necessary
require
  • line_min <= line_max + 1
  • column_min <= column_max + 1
ensure
make (line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
{ANY}
Reset all bounds line_minimum / line_maximum / column_minimum and column_maximum using arguments as new values.
All elements are set to the default value of type E_.
require
  • line_min <= line_max + 1
  • column_min <= column_max + 1
ensure
from_collection2 (model: COLLECTION2[E_])
effective procedure
{ANY}
Uses model to initialize Current.
require
  • model /= Void
ensure
  • lower1 = model.lower1
  • lower2 = model.lower2
  • count1 = model.count1
  • count2 = model.count2
from_collection (contents: COLLECTION[E_], line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
{ANY}
Reset all bounds using line_min, line_max, column_min, and column_max . Copy all elements of contents, line by line into Current.
require
  • line_min <= line_max + 1
  • column_min <= column_max + 1
  • contents.count = line_max - line_min + 1 * column_max - column_min + 1
ensure
from_model (model: COLLECTION[COLLECTION[E_]])
effective procedure
{ANY}
The model is used to fill line by line the COLLECTION2.
Assume all sub-collections of model have the same indexing.
require
  • model.count >= 0
  • model.count > 0 implies model.first.count >= 0
ensure
resize (line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
{ANY}
Resize bounds of the Current array
require
  • line_max >= line_min - 1
  • column_max >= column_min - 1
ensure
item (line: INTEGER_32, column: INTEGER_32): E_
effective function
{ANY}
require
  • valid_index(line, column)
put (element: E_, line: INTEGER_32, column: INTEGER_32)
effective procedure
{ANY}
require
  • valid_index(line, column)
ensure
  • item(line, column) = element
count1: INTEGER_32
effective function
{ANY}
Size of the first dimension.
ensure
  • Result = upper1 - lower1 + 1
count2: INTEGER_32
effective function
{ANY}
Size of the second dimension.
ensure
  • Result = upper2 - lower2 + 1
count: INTEGER_32
effective function
{ANY}
Total number of elements.
ensure
  • Result = line_count * column_count
force (x: E_, line: INTEGER_32, column: INTEGER_32)
effective procedure
{ANY}
Put element at position (line,column).
Collection resized first when (line,column) is not inside current bounds. New bounds are initialized with default values.
require(
  • True
) or else (
    • line >= 0
    • column >= 0
) ensure
  • item(line, column) = x
  • count >= old count
set_all_with (element: E_)
effective procedure
{ANY}
Set all item with value v.
ensure
  • count = old count
replace_all (old_value: E_, new_value: E_)
effective procedure
{ANY}
Replace all occurrences of the element old_value by new_value using is_equal for comparison.
See also fast_replace_all to choose the appropriate one.
ensure
  • count = old count
  • occurrences(old_value) = 0
fast_replace_all (old_value: E_, new_value: E_)
effective procedure
{ANY}
Replace all occurrences of the element old_value by new_value using operator = for comparison.
See also replace_all to choose the appropriate one.
ensure
  • count = old count
  • fast_occurrences(old_value) = 0
sub_collection2 (line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32): ARRAY2 [E_]
effective function
{ANY}
Create a new object using selected area of Current.
require
  • valid_index(line_min, column_min)
  • valid_index(line_max, column_max)
  • line_min <= line_max + 1
  • column_min <= column_max + 1
ensure
occurrences (elt: E_): INTEGER_32
effective function
{ANY}
Number of occurrences using is_equal.
See also fast_occurrences to choose the appropriate one.
ensure
  • Result >= 0
fast_occurrences (elt: E_): INTEGER_32
effective function
{ANY}
Number of occurrences using =.
See also occurrences to chose the appropriate one.
ensure
  • Result >= 0
has (x: E_): BOOLEAN
effective function
{ANY}
Search if a element x is in the array using equal.
See also fast_has to chose the apropriate one.
fast_has (x: E_): BOOLEAN
effective function
{ANY}
Search if a element x is in the array using =.
all_default: BOOLEAN
effective function
{ANY}
Do all items have their type's default value?
swap (line1: INTEGER_32, column1: INTEGER_32, line2: INTEGER_32, column2: INTEGER_32)
effective procedure
{ANY}
Swap the element at index (line1,column1) with the the element at index (line2,column2).
require
  • valid_index(line1, column1)
  • valid_index(line2, column2)
ensure
  • item(line1, column1) = old item(line2, column2)
  • item(line2, column2) = old item(line1, column1)
  • count = old count
copy (other: ARRAY2 [E_])
effective procedure
{ANY}
require
    • not immutable
    • same_dynamic_type(other)
    • not immutable
    • same_dynamic_type(other)
ensure
  • is_equal(other)
transpose
effective procedure
{ANY}
Transpose the Current array
to_external: POINTER
effective function
{ANY}
Gives C access to the internal storage (may be dangerous).
mark_native_arrays
effective procedure
{}
For performance reasons, the unused area of storage is always left as it is when some elements are removed.
No time is lost to clean the released area with a Void or a 0 value. Thus, the unused area of storage may contains references of actually unreachable objects. The following mark_native_arrays actually replace the default behavior (the call is automatic) in order to mark only reachable objects.
manifest_make (needed_capacity: INTEGER_32, line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
{}
Create an ARRAY2[E_] using line_minimum / line_maximum / column_minimum and column_maximum as bounds.
require
  • line_min <= line_max
  • column_min <= column_max
  • needed_capacity = line_max - line_min + 1 * column_max - column_min + 1
manifest_put (index: INTEGER_32, element: E_)
effective procedure
{}
The elements are stored line by line.
require
  • index >= 0
line_minimum: INTEGER_32
frozen
effective function
{ANY}
Equivalent of lower1.
column_minimum: INTEGER_32
frozen
effective function
{ANY}
Equivalent of lower2.
line_maximum: INTEGER_32
frozen
effective function
{ANY}
Equivalent of upper1.
column_maximum: INTEGER_32
frozen
effective function
{ANY}
Equivalent of upper2.
valid_line (line: INTEGER_32): BOOLEAN
frozen
effective function
{ANY}
ensure
valid_index1 (line: INTEGER_32): BOOLEAN
effective function
{ANY}
ensure
valid_column (column: INTEGER_32): BOOLEAN
frozen
effective function
{ANY}
ensure
valid_index2 (column: INTEGER_32): BOOLEAN
effective function
{ANY}
ensure
valid_index (line: INTEGER_32, column: INTEGER_32): BOOLEAN
frozen
effective function
{ANY}
ensure
line_count: INTEGER_32
frozen
effective function
{ANY}
Equivalent of count1.
column_count: INTEGER_32
frozen
effective function
{ANY}
clear_all
frozen
effective procedure
{ANY}
Set all items to default values.
ensure
fast_is_equal (other: ARRAY2 [E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower1, lower2, upper1 and upper2, and items?
The basic = is used for comparison of items. See also is_equal.
is_equal (other: ARRAY2 [E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower1, lower2, upper1 and upper2, and items?
Feature is_equal is used for comparison of items. See also fast_is_equal.
require
  • other /= Void
ensure
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)
is_equal_map (other: ARRAY2 [E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower, upper, and items?
This feature is obsolete: Use `is_equal' instead.
fill_tagged_out_memory
frozen
effective procedure
{ANY}
Append a viewable information in tagged_out_memory in order to affect the behavior of out, tagged_out, etc.
require
  • locked: tagged_out_locked
ensure
  • still_locked: tagged_out_locked
set_area (element: E_, line_min: INTEGER_32, line_max: INTEGER_32, column_min: INTEGER_32, column_max: INTEGER_32)
effective procedure
{ANY}
Set all the elements of the selected area rectangle with element.
require ensure
manifest_semicolon_check: BOOLEAN
is True
constant attribute
{}
You can use semicolons to make the end of each line more visible.
test (e1: E_, e2: E_): BOOLEAN
effective function
{ANY}
In order to avoid run-time type errors, feature safe_equal calls is_equal only when e1 and e2 have exactly the same dynamic type.
safe_equal (e1: E_, e2: E_): BOOLEAN
effective function
{ANY}
In order to avoid run-time type errors, feature safe_equal calls is_equal only when e1 and e2 have exactly the same dynamic type.
mark_item (native_array: NATIVE_ARRAY[E_], index: INTEGER_32)
{}
To be used _only_ inside the definition of mark_native_arrays.
Forces the garbage collector to continue the marking process on the index-th element of the native_array. The element at index can be Void or not Void (the Void-ness test performed inside the mark_item itself).