indexing
description: "Contiguous integer intervals"
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
revision: "$Revision: 56675 $"
class interface
INTEGER_INTERVAL
create
make (min_index, max_index: INTEGER_32)
`min_index'
`max_index'`min_index'`max_index'
ensure
lower_defined: lower_defined
upper_defined: upper_defined
set_if_non_empty: (min_index <= max_index) implies ((lower = min_index) and (upper = max_index))
empty_if_not_in_order: (min_index > max_index) implies is_empty
feature
adapt (other: INTEGER_INTERVAL)
`other'
require
other_not_void: other /= Void
ensure
same_lower: lower = other.lower
same_upper: upper = other.upper
same_lower_defined: lower_defined = other.lower_defined
same_upper_defined: upper_defined = other.upper_defined
feature
generating_type: STRING_8
ANY
generator: STRING_8
ANY
has (v: INTEGER_32): BOOLEAN
`v'
INTEGER_INTERVALvalid_index
require CONTAINER
True
ensure CONTAINER
not_found_in_empty: Result implies not is_empty
ensure then
iff_within_bounds: Result = ((upper_defined implies v <= upper) and (lower_defined implies v >= lower))
item alias "[]" (i: INTEGER_32): INTEGER_32
`i'
INTEGER_INTERVALinfix "@"
require TABLE
valid_key: valid_index (i)
lower: INTEGER_32
require
lower_defined: lower_defined
lower_defined: BOOLEAN
upper: INTEGER_32
require
upper_defined: upper_defined
upper_defined: BOOLEAN
valid_index (v: INTEGER_32): BOOLEAN
`v'
INTEGER_INTERVALhas
require TABLE
True
ensure then INDEXABLE
only_if_in_index_set: Result implies ((v >= index_set.lower) and (v <= index_set.upper))
ensure then
iff_within_bounds: Result = ((upper_defined implies v <= upper) and (lower_defined implies v >= lower))
infix "@" (i: INTEGER_32): INTEGER_32
`i'
INTEGER_INTERVALitem
require TABLE
valid_key: valid_index (i)
feature
additional_space: INTEGER_32
RESIZABLE
ensure RESIZABLE
at_least_one: Result >= 1
capacity: INTEGER_32
count
count: INTEGER_32
require SET
True
require FINITE
True
ensure then
definition: Result = upper - lower + 1
growth_percentage: INTEGER_32 is 50
RESIZABLE
index_set: INTEGER_INTERVAL
require INDEXABLE
True
ensure INDEXABLE
not_void: Result /= Void
ensure then
index_set_is_range: equal (Result, Current)
minimal_increase: INTEGER_32 is 5
RESIZABLE
occurrences (v: INTEGER_32): INTEGER_32
`v'
require BAG
True
ensure BAG
non_negative_occurrences: Result >= 0
ensure then
one_iff_in_bounds: Result = 1 implies has (v)
zero_otherwise: Result /= 1 implies Result = 0
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'
require ANY
other_not_void: other /= Void
ensure ANY
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
ensure then
iff_same_bounds: Result = ((lower_defined implies (other.lower_defined and lower = other.lower)) and (upper_defined implies (other.upper_defined and upper = other.upper)))
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
all_cleared: BOOLEAN
ensure then
iff_at_zero: Result = ((lower = 0) and (upper = 0))
conforms_to (other: ANY): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
extendible: BOOLEAN
full: BOOLEAN
BOUNDED
is_empty: BOOLEAN
FINITE
require CONTAINER
True
is_inserted (v: INTEGER_32): BOOLEAN
`v'
`has (v)'
COLLECTION
object_comparison: BOOLEAN
equal`='
`='
CONTAINER
prunable: BOOLEAN
resizable: BOOLEAN
capacity
RESIZABLE
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))
feature
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
extend (v: INTEGER_32)
`v'
INTEGER_INTERVALput
require COLLECTION
extendible: extendible
ensure COLLECTION
item_inserted: is_inserted (v)
ensure then SET
in_set_already: old has (v) implies (count = old count)
added_to_set: not old has (v) implies (count = old count + 1)
ensure then BAG
one_more_occurrence: occurrences (v) = old (occurrences (v)) + 1
ensure then
extended_down: lower = (old lower).min (v)
extended_up: upper = (old upper).max (v)
fill (other: CONTAINER [INTEGER_32])
`other'
`other'
COLLECTION
require COLLECTION
other_not_void: other /= Void
extendible: extendible
put (v: INTEGER_32)
`v'
INTEGER_INTERVALextend
require COLLECTION
extendible: extendible
ensure COLLECTION
item_inserted: is_inserted (v)
ensure then SET
in_set_already: old has (v) implies (count = old count)
added_to_set: not old has (v) implies (count = old count + 1)
ensure then
extended_down: lower = (old lower).min (v)
extended_up: upper = (old upper).max (v)
feature
changeable_comparison_criterion: BOOLEAN
object_comparison
SET
require CONTAINER
True
ensure then SET
only_on_empty: Result = is_empty
prune_all (v: INTEGER_32)
`v'
object_comparison
COLLECTION
require COLLECTION
prunable: prunable
ensure COLLECTION
no_more_occurrences: not has (v)
wipe_out
require COLLECTION
prunable: prunable
ensure COLLECTION
wiped_out: is_empty
feature
automatic_grow
Growth_percentage
RESIZABLE
ensure RESIZABLE
increased_capacity: capacity >= old capacity + old capacity * growth_percentage // 100
grow (i: INTEGER_32)
`i'
require RESIZABLE
True
ensure RESIZABLE
new_capacity: capacity >= i
ensure then
no_loss_from_bottom: lower <= old lower
no_loss_from_top: upper >= old upper
resize (min_index, max_index: INTEGER_32)
`min_index'`max_index'
resize_exactly (min_index, max_index: INTEGER_32)
`min_index'`max_index'
feature
as_array: ARRAY [INTEGER_32]
require
finite: upper_defined and lower_defined
ensure
same_lower: Result.lower = lower
same_upper: Result.upper = upper
linear_representation: LINEAR [INTEGER_32]
feature
copy (other: like Current)
`other'
require ANY
other_not_void: other /= Void
type_identity: same_type (other)
ensure ANY
is_equal: is_equal (other)
ensure then
same_lower: lower = other.lower
same_upper: upper = other.upper
same_lower_defined: lower_defined = other.lower_defined
same_upper_defined: upper_defined = other.upper_defined
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)
subinterval (start_pos, end_pos: INTEGER_32): like Current
`start_pos'`end_pos'
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
do_all (action: PROCEDURE [ANY, TUPLE [INTEGER_32]])
`action'
require
action_exists: action /= Void
finite: upper_defined and lower_defined
exists (condition: FUNCTION [ANY, TUPLE [INTEGER_32], BOOLEAN]): BOOLEAN
`condition'
require
finite: upper_defined and lower_defined
condition_not_void: condition /= Void
ensure
consistent_with_count: Result = (hold_count (condition) > 0)
exists1 (condition: FUNCTION [ANY, TUPLE [INTEGER_32], BOOLEAN]): BOOLEAN
`condition'
require
finite: upper_defined and lower_defined
condition_not_void: condition /= Void
ensure
consistent_with_count: Result = (hold_count (condition) = 1)
for_all (condition: FUNCTION [ANY, TUPLE [INTEGER_32], BOOLEAN]): BOOLEAN
`condition'
require
finite: upper_defined and lower_defined
condition_not_void: condition /= Void
ensure
consistent_with_count: Result = (hold_count (condition) = count)
hold_count (condition: FUNCTION [ANY, TUPLE [INTEGER_32], BOOLEAN]): INTEGER_32
`condition'
require
finite: upper_defined and lower_defined
condition_not_void: condition /= Void
ensure
non_negative: Result >= 0
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
count_definition: upper_defined and lower_defined implies count = upper - lower + 1
index_set_is_range: equal (index_set, Current)
not_infinite: upper_defined and lower_defined
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
ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)
INDEXABLE
index_set_not_void: index_set /= Void
indexing
library: "EiffelBase: Library of reusable components for Eiffel."
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 INTEGER_INTERVAL