deferred class COLLECTION3 [E_]

Features exported to ANY

Abstract definition of a 3 dimensional collection of elements of type E_.

The SmartEiffel standard library provides two implementations of COLLECTION3: ARRAY3 and FIXED_ARRAY3. All implementations have exactly the same behavior. Switching from one implementation to another only change the memory used and the execution time.

Direct parents

conformant parents

SAFE_EQUAL

Known children

conformant children

ARRAY3, FAST_ARRAY3

Summary

exported features

Indexing:

Reading:

Writing:

Index validity:

Counting:

Creating or initializing:

Looking and comparison:

Printing:

Miscellaneous features:

Details

deferred lower1: INTEGER

Lower index bound for dimension 1.

deferred lower2: INTEGER

Lower index bound for dimension 2.

deferred lower3: INTEGER

Lower index bound for dimension 3.

frozen line_minimum: INTEGER

Equivalent of lower1.

frozen column_minimum: INTEGER

Equivalent of lower2.

frozen depth_minimum: INTEGER

Equivalent of lower3.

deferred upper1: INTEGER

Upper index bound for dimension 1.

deferred upper2: INTEGER

Upper index bound for dimension 2.

deferred upper3: INTEGER

Upper index bound for dimension 3.

frozen line_maximum: INTEGER

Equivalent of upper1.

frozen column_maximum: INTEGER

Equivalent of upper2.

frozen depth_maximum: INTEGER

Equivalent of upper3.

deferred item (line: INTEGER, column: INTEGER, depth: INTEGER): E_

require

  • valid_index(line, column, depth)

deferred put (element: E_, line: INTEGER, column: INTEGER, depth: INTEGER)

require

  • valid_index(line, column, depth)

ensure

  • item(line, column, depth) = element

deferred force (element: E_, line: INTEGER, column: INTEGER, depth: INTEGER)

Put element at position (line,column,depth). Collection is resized first when (line,column,depth) is not inside current bounds. New bounds are initialized with default values.

require

  • line >= 0
  • column >= 0
  • depth >= 0

ensure

  • item(line, column, depth) = element
  • count >= old count

frozen valid_line (line: INTEGER): BOOLEAN

ensure

  • Result = (lower1 <= line and line <= upper1)

valid_index1 (line: INTEGER): BOOLEAN

ensure

  • Result = (lower1 <= line and line <= upper1)

frozen valid_column (column: INTEGER): BOOLEAN

ensure

  • Result = (lower2 <= column and column <= upper2)

valid_index2 (column: INTEGER): BOOLEAN

ensure

  • Result = (lower2 <= column and column <= upper2)

frozen valid_depth (depth: INTEGER): BOOLEAN

ensure

  • Result = (lower3 <= depth and depth <= upper3)

valid_index3 (depth: INTEGER): BOOLEAN

ensure

  • Result = (lower3 <= depth and depth <= upper3)

frozen valid_index (line: INTEGER, column: INTEGER, depth: INTEGER): BOOLEAN

ensure

  • Result = (valid_line(line) and valid_column(column) and valid_depth(depth))

deferred count1: INTEGER

Size of the first dimension.

ensure

  • Result = upper1 - lower1 + 1

frozen line_count: INTEGER

Equivalent of count1.

deferred count2: INTEGER

Size of the second dimension.

ensure

  • Result = upper2 - lower2 + 1

frozen column_count: INTEGER
deferred count3: INTEGER

Size of the third dimension.

ensure

  • Result = upper3 - lower3 + 1

frozen depth_count: INTEGER
deferred count: INTEGER

Total number of elements.

ensure

  • Result = line_count * column_count * depth_count

deferred swap (line1: INTEGER, column1: INTEGER, depth1: INTEGER, line2: INTEGER, column2: INTEGER, depth2: INTEGER)

Swap the element at index (line1,column1,depth1) with the element at index (line2,column2,depth2).

require

  • valid_index(line1, column1, depth1)
  • valid_index(line2, column2, depth2)

ensure

  • item(line1, column1, depth1) = old item(line2, column2, depth2)
  • item(line2, column2, depth2) = old item(line1, column1, depth1)
  • count = old count

deferred set_all_with (v: E_)

Set all item with value v.

ensure

  • count = old count

frozen clear_all

Set all items to default values.

ensure

  • count = old count
  • all_default

deferred from_collection3 (model: COLLECTION3[E_])
 Uses model to initialize Current.

require

  • model /= Void

ensure

  • count1 = model.count1
  • count2 = model.count2
  • count3 = model.count3

deferred from_model (model: COLLECTION[COLLECTION[COLLECTION[E_]]])

The model is used to fill line by line Current. Assume all sub-collections have the same dimension.

require

  • model /= Void

ensure

  • count1 = model.count
  • count2 > 0 implies count2 = model.first.count
  • count3 > 0 implies count3 = model.first.first.count

deferred all_default: BOOLEAN

Do all items have their type's default value?

is_equal (other: COLLECTION3[E_]): BOOLEAN

Do both collections have the same lower1, lower2, lower3, upper1, upper2 and upper3, and items? The basic = is used for comparison of items. See also is_equal_map.

require

  • other /= Void

ensure

  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)

is_equal_map (other: COLLECTION3[E_]): BOOLEAN

Do both collections have the same lower1, lower2, lower3, upper1, upper2 and upper3, and items? Feature is_equal is used for comparison of items. See also is_equal.

same_as (other: COLLECTION3[E_]): BOOLEAN
This feature is obsolete: Now you can just use `is_equal'. (July 7th2004)
frozen fill_tagged_out_memory

Append a viewable information in tagged_out_memory in order to affect the behavior of out, tagged_out, etc.

deferred occurrences (elt: E_): INTEGER

Number of occurrences using is_equal. See also fast_occurrences to choose the apropriate one.

ensure

  • Result >= 0

deferred fast_occurrences (elt: E_): INTEGER

Number of occurrences using =. See also occurrences to choose the apropriate one.

ensure

  • Result >= 0

deferred has (x: E_): BOOLEAN

Search if a element x is in the array using is_equal. See also fast_has to choose the apropriate one.

deferred fast_has (x: E_): BOOLEAN
 Search if a element x is in the array using =.
deferred replace_all (old_value: E_, new_value: E_)

Replace all occurrences of the element old_value by new_value using is_equal for comparison. See also fast_replace_all to choose the apropriate one.

ensure

  • count = old count
  • occurrences(old_value) = 0

deferred fast_replace_all (old_value: E_, new_value: E_)

Replace all occurrences of the element old_value by new_value using operator = for comparison. See also replace_all to choose the apropriate one.

ensure

  • count = old count
  • fast_occurrences(old_value) = 0

deferred sub_collection3 (line_min: INTEGER, line_max: INTEGER, column_min: INTEGER, column_max: INTEGER, depth_min: INTEGER, depth_max: INTEGER): COLLECTION3 [E_]

Create a new object using selected area of Current.

require

  • valid_index(line_min, column_min, depth_min)
  • valid_index(line_max, column_max, depth_max)

ensure

  • Result /= Void

set_area (element: E_, line_min: INTEGER, line_max: INTEGER, column_min: INTEGER, column_max: INTEGER, depth_min: INTEGER, depth_max: INTEGER)

Set all the elements of the selected area rectangle with element.

require

  • valid_index(line_min, column_min, depth_min)
  • valid_index(line_max, column_max, depth_max)

ensure

  • count = old count

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. Furthermore, this feature avoids argument passing from some expanded type to the corresponding reference type (no automatic allocation of some reference type during the comparison).

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. Furthermore, this feature avoids argument passing from some expanded type to the corresponding reference type (no automatic allocation of some reference type during the comparison).