indexing
description: "Implementation of TUPLE"
status: "See notice at end of class"
date: "$Date$"
revision: "$Revision$"
class interface
TUPLE
create
make
feature
array_make (min_index, max_index: INTEGER)
min_indexmax_index
min_indexmax_index
ARRAY
require ARRAY
valid_bounds: min_index <= max_index + 1
ensure ARRAY
lower_set: lower = min_index
upper_set: upper = max_index
items_set: all_default
make_from_array (a: ARRAY [ANY])
a
ARRAY
ARRAY
require ARRAY
array_exists: a /= void
feature
area: SPECIAL [ANY]
TO_SPECIAL
boolean_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_boolean: is_boolean_item (index)
character_item (index: INTEGER): CHARACTER
index
require
valid_index: valid_index (index)
is_character: is_character_item (index)
double_item (index: INTEGER): DOUBLE
index
require
valid_index: valid_index (index)
is_numeric: is_numeric_item (index)
entry (i: INTEGER): ANY
i
ARRAY
require ARRAY
valid_key: valid_index (i)
has (v: ANY): BOOLEAN
v
object_comparison
ARRAY
ensure CONTAINER
not_found_in_empty: Result implies not is_empty
integer_item (index: INTEGER): INTEGER
index
require
valid_index: valid_index (index)
is_integer: is_integer_item (index)
item (i: INTEGER): ANY
i
ARRAY@
ARRAY
require TABLE
valid_key: valid_index (k)
pointer_item (index: INTEGER): POINTER
index
require
valid_index: valid_index (index)
is_pointer: is_pointer_item (index)
real_item (index: INTEGER): REAL
index
require
valid_index: valid_index (index)
is_real_or_integer: is_real_item (index) or else is_integer_item (index)
infix "@" (i: INTEGER): ANY
i
ARRAYitem
ARRAY
require TABLE
valid_key: valid_index (k)
feature
additional_space: INTEGER
RESIZABLE
ensure RESIZABLE
at_least_one: Result >= 1
capacity: INTEGER
ARRAYcount
ARRAY
ensure then ARRAY
consistent_with_bounds: Result = upper - lower + 1
count: INTEGER
ARRAYcapacity
ARRAY
ensure then ARRAY
consistent_with_bounds: Result = upper - lower + 1
Growth_percentage: INTEGER is 50
RESIZABLE
index_set: INTEGER_INTERVAL
ARRAY
ensure INDEXABLE
not_void: Result /= void
ensure then ARRAY
same_count: Result.count = count
same_bounds: ((Result.lower = lower) and (Result.upper = upper))
lower: INTEGER
ARRAY
Minimal_increase: INTEGER is 5
RESIZABLE
occurrences (v: ANY): INTEGER
v
ARRAY
ensure BAG
non_negative_occurrences: Result >= 0
upper: INTEGER
ARRAY
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
all_default: BOOLEAN
ARRAY
ensure ARRAY
definition: Result = (count = 0 or else ((item (upper) = void or else item (upper) = item (upper).default) and subarray (lower, upper - 1).all_default))
changeable_comparison_criterion: BOOLEAN
object_comparison
CONTAINER
extendible: BOOLEAN
ARRAY
full: BOOLEAN
ARRAY
is_empty: BOOLEAN
FINITE
is_inserted (v: ANY): BOOLEAN
v
COLLECTION
object_comparison: BOOLEAN
equal=
=
CONTAINER
prunable: BOOLEAN
ARRAY
resizable: BOOLEAN
capacity
RESIZABLE
same_items (other: like Current): BOOLEAN
other
ARRAY
require ARRAY
other_not_void: other /= void
ensure ARRAY
definition: Result = ((count = other.count) and then (count = 0 or else (item (upper) = other.item (other.upper) and subarray (lower, upper - 1).same_items (other.subarray (other.lower, other.upper - 1)))))
valid_index (i: INTEGER): BOOLEAN
i
ARRAY
ensure then INDEXABLE
only_if_in_index_set: Result implies ((i >= index_set.lower) and (i <= index_set.upper))
valid_index_set: BOOLEAN
ARRAY
feature
compare_objects
equal
=
CONTAINER
require CONTAINER
changeable_comparison_criterion
ensure CONTAINER
object_comparison
compare_references
=
equal
CONTAINER
require CONTAINER
changeable_comparison_criterion
ensure CONTAINER
reference_comparison: not object_comparison
feature
enter (v: like item; i: INTEGER)
iv
ARRAY
require ARRAY
valid_key: valid_index (i)
fill (other: CONTAINER [ANY])
other
other
COLLECTION
require COLLECTION
other_not_void: other /= void
extendible
force (v: like item; i: INTEGER)
vi
i
ARRAY
ensure ARRAY
inserted: item (i) = v
higher_count: count >= old count
put (v: like item; i: INTEGER)
iv
ARRAY
require TABLE
valid_key: valid_index (k)
ensure then INDEXABLE
insertion_done: item (k) = v
subcopy (other: like Current; start_pos, end_pos, index_pos: INTEGER)
otherstart_posend_pos
index_pos
ARRAY
require ARRAY
other_not_void: other /= void
valid_start_pos: other.valid_index (start_pos)
valid_end_pos: other.valid_index (end_pos)
valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
valid_index_pos: valid_index (index_pos)
enough_space: (upper - index_pos) >= (end_pos - start_pos)
feature
clear_all
ARRAY
ensure ARRAY
stable_lower: lower = old lower
stable_upper: upper = old upper
default_items: all_default
discard_items
ARRAY
ensure ARRAY
default_items: all_default
prune_all (v: ANY)
v
object_comparison
COLLECTION
require COLLECTION
prunable
ensure COLLECTION
no_more_occurrences: not has (v)
feature
automatic_grow
Growth_percentage
RESIZABLE
ensure RESIZABLE
increased_capacity: capacity >= old capacity + old capacity * growth_percentage // 100
grow (i: INTEGER)
i
ARRAY
ensure RESIZABLE
new_capacity: capacity >= i
resize (min_index, max_index: INTEGER)
min_indexmax_index
ARRAY
require ARRAY
good_indices: min_index <= max_index
ensure ARRAY
no_low_lost: lower = min_index or else lower = old lower
no_high_lost: upper = max_index or else upper = old upper
feature
arrayed: ARRAY [ANY]
ensure
exists: Result /= void
same_count: Result.count = count
boolean_arrayed: ARRAY [BOOLEAN]
require
is_uniform_boolean: is_uniform_boolean
ensure
exists: Result /= void
same_count: Result.count = count
character_arrayed: ARRAY [CHARACTER]
require
is_uniform_character: is_uniform_character
ensure
exists: Result /= void
same_count: Result.count = count
double_arrayed: ARRAY [DOUBLE]
require
convertible: convertible_to_double
ensure
exists: Result /= void
same_count: Result.count = count
integer_arrayed: ARRAY [INTEGER]
require
is_uniform_integer: is_uniform_integer
ensure
exists: Result /= void
same_count: Result.count = count
linear_representation: LINEAR [ANY]
ARRAY
pointer_arrayed: ARRAY [POINTER]
require
is_uniform_pointer: is_uniform_pointer
ensure
exists: Result /= void
same_count: Result.count = count
real_arrayed: ARRAY [REAL]
require
convertible: convertible_to_real
ensure
exists: Result /= void
same_count: Result.count = count
string_arrayed: ARRAY [STRING]
STRING
ensure
exists: Result /= void
same_count: Result.count = count
to_c: ANY
ARRAY
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)
subarray (start_pos, end_pos: INTEGER): like Current
start_posend_pos
ARRAY
require ARRAY
valid_start_pos: valid_index (start_pos)
valid_end_pos: valid_index (end_pos)
valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
ensure ARRAY
lower: Result.lower = start_pos
upper: Result.upper = end_pos
feature
make
feature
convertible_to_double: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
convertible_to_real: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
feature
is_boolean_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_character_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_double_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_integer_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_numeric_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_pointer_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_real_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_reference_item (index: INTEGER): BOOLEAN
index
require
valid_index: valid_index (index)
is_uniform: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_boolean: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_character: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_double: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_integer: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_pointer: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_real: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
is_uniform_reference: BOOLEAN
ensure
yes_if_empty: (count = 0) implies Result
invariant
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
library: "[
EiffelBase: Library of reusable components for Eiffel.
]"
status: "[
Copyright 1986-2001 Interactive Software Engineering (ISE).
For ISE customers the original versions are an ISE product
covered by the ISE Eiffel license and support agreements.
]"
license: "[
EiffelBase may now be used by anyone as FREE SOFTWARE to
develop any product, public-domain or commercial, without
payment to ISE, under the terms of the ISE Free Eiffel Library
License (IFELL) at http://eiffel.com/products/base/license.html.
]"
source: "[
Interactive Software Engineering Inc.
ISE Building
360 Storke Road, Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Electronic mail <info@eiffel.com>
Customer support http://support.eiffel.com
]"
info: "[
For latest info see award-winning pages: http://eiffel.com
]"
end -- TUPLE