indexing
description: "Multi-dimensional array"
status: "See notice at end of class"
representation: array
access: multi_dimensional_index
size: resizable
contents: generic
date: "$Date$"
revision: "$Revision$"
class interface
ECOM_ARRAY [G]
create
make (a_dimension_count: INTEGER; some_lower_indices, some_element_counts: ARRAY [INTEGER])
a_dimensional_count
some_lower_indices
some_element_counts
require
valid_dimension_count: a_dimension_count >= 0
valid_lower_indices: some_lower_indices /= void and then some_lower_indices.count = a_dimension_count and (a_dimension_count > 0 implies some_lower_indices.lower = 1)
valid_element_count: some_element_counts /= void and then some_element_counts.count = a_dimension_count and (a_dimension_count > 0 implies some_element_counts.lower = 1) and then are_element_counts_valid (some_element_counts)
ensure
valid_dimension_count: dimension_count >= 0
valid_element_counts: element_counts /= void and then element_counts.count = dimension_count
valid_lower_indices: lower_indices /= void and then lower_indices.count = dimension_count
valid_upper_indices: upper_indices /= void and then upper_indices.count = dimension_count
make_from_array (a: ARRAY [G]; a_dimension_count: INTEGER; some_lower_indices, some_element_counts: ARRAY [INTEGER])
a_dimensional_count
some_lower_indices
some_element_counts
require
valid_dimension_count: a_dimension_count >= 0
valid_lower_indices: some_lower_indices /= void and then some_lower_indices.count = a_dimension_count and (a_dimension_count > 0 implies some_lower_indices.lower = 1)
valid_element_count: some_element_counts /= void and then some_element_counts.count = a_dimension_count and (a_dimension_count > 0 implies some_element_counts.lower = 1) and then are_element_counts_valid (some_element_counts)
valid_array_size: a.count >= total_count (some_element_counts)
ensure
valid_dimension_count: dimension_count >= 0
valid_element_counts: element_counts /= void and then element_counts.count = dimension_count
valid_lower_indices: lower_indices /= void and then lower_indices.count = dimension_count
valid_upper_indices: upper_indices /= void and then upper_indices.count = dimension_count
make_empty
feature
initialize (v: G)
v
feature
item (some_indices: ARRAY [INTEGER]): G
some_indices
require
valid_indices: are_indices_valid (some_indices)
feature
area: SPECIAL [G]
TO_SPECIAL
array_item (i: INTEGER): G
i
ARRAY@
ARRAY
require TABLE
valid_key: valid_index (k)
feature
dimension_count: INTEGER
element_counts: ARRAY [INTEGER]
lower_indices: ARRAY [INTEGER]
upper_indices: ARRAY [INTEGER]
feature
count: INTEGER
ARRAYcapacity
ARRAY
ensure then ARRAY
consistent_with_bounds: Result = upper - lower + 1
feature
is_equal (other: like Current): BOOLEAN
other
ARRAY
require ANY
other_not_void: other /= void
ensure ANY
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
feature
are_element_counts_consistent: BOOLEAN
element_counts
are_element_counts_valid (some_element_counts: ARRAY [INTEGER]): BOOLEAN
some_element_counts
require
non_void_element_counts: some_element_counts /= void
valid_element_counts: (some_element_counts.count > 0 implies some_element_counts.lower = 1)
are_indices_large_enough (some_indices: ARRAY [INTEGER]): BOOLEAN
some_indices
are_indices_valid (some_indices: ARRAY [INTEGER]): BOOLEAN
some_indices
total_count (some_element_counts: ARRAY [INTEGER]): INTEGER
require
valid_counts: are_element_counts_valid (some_element_counts)
ensure
valid_count: Result >= 0
feature
force (v: like item; some_indices: ARRAY [INTEGER])
vsome_indices
require
valid_indices: are_indices_large_enough (some_indices)
ensure
element_inserted: item (some_indices) = v
put (v: like item; some_indices: ARRAY [INTEGER])
vsome_indices
require
valid_indices: are_indices_valid (some_indices)
ensure
element_inserted: item (some_indices) = v
feature
discard_items
ensure ARRAY
default_items: all_default
feature
resize (n_upper_indices: ARRAY [INTEGER])
n_upper_indices
require
are_indices_large_enough (n_upper_indices)
feature
copy (other: like Current)
other
clone
ARRAY
require ANY
other_not_void: other /= void
type_identity: same_type (other)
ensure ANY
is_equal: is_equal (other)
ensure then ARRAY
equal_areas: area.is_equal (other.area)
invariant
consistent_upper_indices: upper_indices.count = dimension_count
consistent_lower_indices: lower_indices.count = dimension_count
consistent_element_counts: are_element_counts_consistent
consistent_size: capacity = total_count (element_counts)
non_negative_count: count >= 0
ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)
ARRAY
area_exists: area /= void
consistent_size: capacity = upper - lower + 1
non_negative_count: count >= 0
index_set_has_same_count: valid_index_set
RESIZABLE
increase_by_at_least_one: minimal_increase >= 1
BOUNDED
valid_count: count <= capacity
full_definition: full = (count = capacity)
FINITE
empty_definition: is_empty = (count = 0)
non_negative_count: count >= 0
INDEXABLE
index_set_not_void: index_set /= void
end -- ECOM_ARRAY