indexing
description: "Multi-dimensional array"
legal: "See notice at end of class."
status: "See notice at end of class."
representation: array
access: multi_dimensional_index
size: resizable
contents: generic
date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
revision: "$Revision: 56675 $"
class interface
ECOM_ARRAY [G]
create
make (a_dimension_count: INTEGER_32; some_lower_indices, some_element_counts: ARRAY [INTEGER_32])
`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_32; some_lower_indices, some_element_counts: ARRAY [INTEGER_32])
`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
generating_type: STRING_8
ANY
generator: STRING_8
ANY
item (some_indices: ARRAY [INTEGER_32]): G
`some_indices'
require
valid_indices: are_indices_valid (some_indices)
feature {ANY}
area: SPECIAL [G]
TO_SPECIAL
item alias "[]" (i: INTEGER_32): G assign put
`i'
ARRAYinfix "@"
ARRAY
require TABLE
valid_key: valid_index (i)
require TO_SPECIAL
valid_index: valid_index (i)
feature
dimension_count: INTEGER_32
element_counts: ARRAY [INTEGER_32]
lower_indices: ARRAY [INTEGER_32]
upper_indices: ARRAY [INTEGER_32]
feature {ANY}
count: INTEGER_32
ARRAYcapacity
ARRAY
require FINITE
True
ensure then ARRAY
consistent_with_bounds: Result = upper - lower + 1
feature
frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
shallow_implies_deep: standard_equal (some, other) implies Result
both_or_none_void: (some = Void) implies (Result = (other = Void))
same_type: (Result and (some /= Void)) implies some.same_type (other)
symmetric: Result implies deep_equal (other, some)
frozen equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))
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
frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))
frozen standard_is_equal (other: like Current): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
ensure ANY
same_type: Result implies same_type (other)
symmetric: Result implies other.standard_is_equal (Current)
feature
are_element_counts_consistent: BOOLEAN
element_counts
are_element_counts_valid (some_element_counts: ARRAY [INTEGER_32]): 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_32]): BOOLEAN
`some_indices'
are_indices_valid (some_indices: ARRAY [INTEGER_32]): BOOLEAN
`some_indices'
conforms_to (other: ANY): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
same_type (other: ANY): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
ensure ANY
definition: Result = (conforms_to (other) and other.conforms_to (Current))
total_count (some_element_counts: ARRAY [INTEGER_32]): INTEGER_32
require
valid_counts: are_element_counts_valid (some_element_counts)
ensure
valid_count: Result >= 0
feature {ANY}
changeable_comparison_criterion: BOOLEAN
object_comparison
CONTAINER
object_comparison: BOOLEAN
equal`='
`='
CONTAINER
valid_index (i: INTEGER_32): BOOLEAN
`i'
ARRAY
require TABLE
True
require TO_SPECIAL
True
ensure then INDEXABLE
only_if_in_index_set: Result implies ((i >= index_set.lower) and (i <= index_set.upper))
feature {ANY}
compare_objects
equal
`='
CONTAINER
require CONTAINER
changeable_comparison_criterion: changeable_comparison_criterion
ensure CONTAINER
object_comparison
compare_references
`='
equal
CONTAINER
require CONTAINER
changeable_comparison_criterion: changeable_comparison_criterion
ensure CONTAINER
reference_comparison: not object_comparison
feature
force (v: like item; some_indices: ARRAY [INTEGER_32])
`v'`some_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_32])
`v'`some_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_32])
`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)
frozen deep_copy (other: like Current)
copy`other'deep_twin
ANY
require ANY
other_not_void: other /= Void
ensure ANY
deep_equal: deep_equal (Current, other)
frozen deep_twin: like Current
ANY
ensure ANY
deep_equal: deep_equal (Current, Result)
frozen standard_copy (other: like Current)
`other'
ANY
require ANY
other_not_void: other /= Void
type_identity: same_type (other)
ensure ANY
is_standard_equal: standard_is_equal (other)
frozen standard_twin: like Current
`other'
ANY
ensure ANY
standard_twin_not_void: Result /= Void
equal: standard_equal (Result, Current)
frozen twin: like Current
`Current'
twincopycopy
ANY
ensure ANY
twin_not_void: Result /= Void
is_equal: Result.is_equal (Current)
feature
frozen default: like Current
ANY
frozen default_pointer: POINTER
`POINTER'
`p'default
`p'`POINTER'
ANY
default_rescue
ANY
frozen do_nothing
ANY
feature
io: STD_FILES
ANY
out: STRING_8
ANYtagged_out
ANY
print (some: ANY)
`some'
ANY
frozen tagged_out: STRING_8
ANYout
ANY
feature
operating_environment: OPERATING_ENVIRONMENT
ANY
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
indexing
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
356 Storke Road, Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end ECOM_ARRAY