Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "[ Contiguous integer interval that calls an action sequence when it changes. ]" status: "See notice at end of class" keywords: "event, action, linked, list" date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" class ACTIVE_INTEGER_INTERVAL create make feature -- Initialization adapt (other: INTEGER_INTERVAL) is -- Reset to be the same interval as other. require -- from INTEGER_INTERVAL other_not_void: other /= void do Precursor {INTEGER_INTERVAL} (other) on_change ensure -- from INTEGER_INTERVAL 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 end feature {NONE} -- Initialization make (min_index, max_index: INTEGER) is -- Set up interval to have bounds min_index and -- max_index (empty if min_index > max_index) -- (from INTEGER_INTERVAL) do lower_defined := True upper_defined := True if min_index <= max_index then lower_internal := min_index upper_internal := max_index else lower_internal := 1 upper_internal := 0 end ensure -- from INTEGER_INTERVAL 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 end feature -- Access has (v: INTEGER): BOOLEAN is -- Does v appear in interval? -- Was declared in INTEGER_INTERVAL as synonym of valid_index. -- (from INTEGER_INTERVAL) do Result := (upper_defined implies v <= upper) and (lower_defined implies v >= lower) ensure -- from CONTAINER not_found_in_empty: Result implies not is_empty ensure then -- from INTEGER_INTERVAL iff_within_bounds: Result = ((upper_defined implies v <= upper) and (lower_defined implies v >= lower)) end item (i: INTEGER): INTEGER is -- Entry at index i, if in index interval -- Was declared in INTEGER_INTERVAL as synonym of @. -- (from INTEGER_INTERVAL) require -- from TABLE valid_key: valid_index (k) do Result := i end lower: INTEGER is -- Smallest value in interval -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL lower_defined: lower_defined do Result := lower_internal end lower_defined: BOOLEAN -- Is there a lower bound? -- (from INTEGER_INTERVAL) upper: INTEGER is -- Largest value in interval -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL upper_defined: upper_defined do Result := upper_internal end upper_defined: BOOLEAN -- Is there an upper bound? -- (from INTEGER_INTERVAL) valid_index (v: INTEGER): BOOLEAN is -- Does v appear in interval? -- Was declared in INTEGER_INTERVAL as synonym of has. -- (from INTEGER_INTERVAL) do Result := (upper_defined implies v <= upper) and (lower_defined implies v >= lower) ensure then -- from INDEXABLE only_if_in_index_set: Result implies ((i >= index_set.lower) and (i <= index_set.upper)) ensure then -- from INTEGER_INTERVAL iff_within_bounds: Result = ((upper_defined implies v <= upper) and (lower_defined implies v >= lower)) end infix "@" (i: INTEGER): INTEGER is -- Entry at index i, if in index interval -- Was declared in INTEGER_INTERVAL as synonym of item. -- (from INTEGER_INTERVAL) require -- from TABLE valid_key: valid_index (k) do Result := i end feature -- Measurement additional_space: INTEGER is -- Proposed number of additional items -- (from RESIZABLE) do Result := (capacity * growth_percentage // 100).max (minimal_increase) ensure -- from RESIZABLE at_least_one: Result >= 1 end capacity: INTEGER is -- Maximum number of items in interval -- (here the same thing as count) -- (from INTEGER_INTERVAL) do check terminal: upper_defined and lower_defined end Result := count end count: INTEGER is -- Number of items in interval -- (from INTEGER_INTERVAL) do check finite: upper_defined and lower_defined end if upper_defined and lower_defined then Result := upper - lower + 1 end ensure then -- from INTEGER_INTERVAL definition: Result = upper - lower + 1 end Growth_percentage: INTEGER is 50 -- Percentage by which structure will grow automatically -- (from RESIZABLE) index_set: INTEGER_INTERVAL is -- Range of acceptable indexes -- (here: the interval itself) -- (from INTEGER_INTERVAL) do Result := Current ensure -- from INDEXABLE not_void: Result /= void ensure then -- from INTEGER_INTERVAL index_set_is_range: equal (Result, Current) end Minimal_increase: INTEGER is 5 -- Minimal number of additional items -- (from RESIZABLE) occurrences (v: INTEGER): INTEGER is -- Number of times v appears in structure -- (from INTEGER_INTERVAL) do if has (v) then Result := 1 end ensure -- from BAG non_negative_occurrences: Result >= 0 ensure then -- from INTEGER_INTERVAL one_iff_in_bounds: Result = 1 implies has (v) zero_otherwise: Result /= 1 implies Result = 0 end feature -- Comparison is_equal (other: like Current): BOOLEAN is -- Is array made of the same items as other? -- (from INTEGER_INTERVAL) require -- from ANY other_not_void: other /= void do Result := (lower_defined implies (other.lower_defined and lower = other.lower)) and (upper_defined implies (other.upper_defined and upper = other.upper)) ensure -- from ANY symmetric: Result implies other.is_equal (Current) consistent: standard_is_equal (other) implies Result ensure then -- from INTEGER_INTERVAL 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))) end feature -- Status report all_cleared: BOOLEAN is -- Are all items set to default values? -- (from INTEGER_INTERVAL) do Result := ((lower = 0) and (upper = 0)) ensure then -- from INTEGER_INTERVAL iff_at_zero: Result = ((lower = 0) and (upper = 0)) end empty: BOOLEAN is obsolete "ELKS 2000: Use `is_empty' instead" -- Is there no element? -- (from CONTAINER) do Result := is_empty end extendible: BOOLEAN is -- May new items be added? -- Answer: yes -- (from INTEGER_INTERVAL) do Result := True end full: BOOLEAN is -- Is structure full? -- (from BOUNDED) do Result := (count = capacity) end is_empty: BOOLEAN is -- Is structure empty? -- (from FINITE) do Result := (count = 0) end is_inserted (v: INTEGER): BOOLEAN is -- Has v been inserted by the most recent insertion? -- (By default, the value returned is equivalent to calling -- `has (v)'. However, descendants might be able to provide more -- efficient implementations.) -- (from COLLECTION) do Result := has (v) end object_comparison: BOOLEAN -- Must search operations use equal rather than = -- for comparing references? (Default: no, use =.) -- (from CONTAINER) prunable: BOOLEAN is -- May individual items be removed? -- Answer: no -- (from INTEGER_INTERVAL) do Result := False end resizable: BOOLEAN is -- May capacity be changed? (Answer: yes.) -- (from RESIZABLE) do Result := True end feature -- Status setting compare_objects is -- Ensure that future search operations will use equal -- rather than = for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := True ensure -- from CONTAINER object_comparison end compare_references is -- Ensure that future search operations will use = -- rather than equal for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion do object_comparison := False ensure -- from CONTAINER reference_comparison: not object_comparison end feature -- Element change extend (v: INTEGER) is -- Make sure that interval goes all the way -- to v (up or down). require -- from COLLECTION extendible: extendible do Precursor {INTEGER_INTERVAL} (v) on_change ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from 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 -- from BAG one_more_occurrence: occurrences (v) = old (occurrences (v)) + 1 ensure then -- from INTEGER_INTERVAL extended_down: lower = (old lower).min (v) extended_up: upper = (old upper).max (v) end fill (other: CONTAINER [INTEGER]) is -- Fill with as many items of other as possible. -- The representations of other and current structure -- need not be the same. -- (from COLLECTION) require -- from COLLECTION other_not_void: other /= void extendible local lin_rep: LINEAR [INTEGER] do lin_rep := other.linear_representation from lin_rep.start until not extendible or else lin_rep.off loop extend (lin_rep.item) lin_rep.forth end end put (v: INTEGER) is -- Make sure that interval goes all the way -- to v (up or down). require -- from INTEGER_INTERVAL True require -- from COLLECTION extendible: extendible do Precursor {INTEGER_INTERVAL} (v) on_change ensure -- from COLLECTION item_inserted: is_inserted (v) ensure then -- from 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 -- from INTEGER_INTERVAL extended_down: lower = (old lower).min (v) extended_up: upper = (old upper).max (v) end feature -- Removal changeable_comparison_criterion: BOOLEAN is -- May object_comparison be changed? -- (Answer: only if set empty; otherwise insertions might -- introduce duplicates, destroying the set property.) -- (from SET) do Result := is_empty ensure then -- from SET only_on_empty: Result = is_empty end prune_all (v: INTEGER) is -- Remove all occurrences of v. -- (Reference or object equality, -- based on object_comparison.) -- (from COLLECTION) require -- from COLLECTION prunable do from until not has (v) loop prune (v) end ensure -- from COLLECTION no_more_occurrences: not has (v) end wipe_out is -- Remove all items. -- (from INTEGER_INTERVAL) require -- from COLLECTION prunable do lower_defined := True upper_defined := True lower_internal := 1 upper_internal := 0 ensure -- from COLLECTION wiped_out: is_empty end feature -- Resizing automatic_grow is -- Change the capacity to accommodate at least -- Growth_percentage more items. -- (from RESIZABLE) do grow (capacity + additional_space) ensure -- from RESIZABLE increased_capacity: capacity >= old capacity + old capacity * growth_percentage // 100 end grow (i: INTEGER) is -- Ensure that capacity is at least i. -- (from INTEGER_INTERVAL) do if capacity < i then resize (lower, lower + i - 1) end ensure -- from RESIZABLE new_capacity: capacity >= i ensure then -- from INTEGER_INTERVAL no_loss_from_bottom: lower <= old lower no_loss_from_top: upper >= old upper end resize (min_index, max_index: INTEGER) is -- Rearrange interval to go from at most -- min_index to at least max_index, -- encompassing previous bounds. do Precursor {INTEGER_INTERVAL} (min_index, max_index) on_change end resize_exactly (min_index, max_index: INTEGER) is -- Rearrange interval to go from -- min_index to max_index. do Precursor {INTEGER_INTERVAL} (min_index, max_index) on_change end feature -- Conversion as_array: ARRAY [INTEGER] is -- Plain array containing interval's items -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined local i: INTEGER do create Result.make (lower, upper) from i := lower until i > upper loop Result.put (i, i) i := i + 1 end ensure -- from INTEGER_INTERVAL same_lower: Result.lower = lower same_upper: Result.upper = upper end linear_representation: LINEAR [INTEGER] is -- Representation as a linear structure -- (from INTEGER_INTERVAL) do check terminal: upper_defined and lower_defined end Result := as_array.linear_representation end to_c: ANY is -- Address of actual sequence of values, -- for passing to external (non-Eiffel) routines. -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined do Result := as_array.to_c end feature -- Duplication copy (other: like Current) is -- Reset to be the same interval as other. require -- from ANY other_not_void: other /= void type_identity: same_type (other) do Precursor {INTEGER_INTERVAL} (other) on_change ensure -- from ANY is_equal: is_equal (other) ensure then -- from INTEGER_INTERVAL 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 end subinterval (start_pos, end_pos: INTEGER): like Current is -- Interval made of items of current array within -- bounds start_pos and end_pos. -- (from INTEGER_INTERVAL) do create Result.make (start_pos, end_pos) end feature {NONE} -- Inapplicable bag_put (v: INTEGER) is -- (from TABLE) require -- from COLLECTION extendible: extendible do ensure -- from COLLECTION item_inserted: is_inserted (v) end indexable_put (v: INTEGER; k: INTEGER) is -- Associate value v with key k. -- Not applicable here. -- (from INTEGER_INTERVAL) require -- from TABLE valid_key: valid_index (k) do ensure then -- from INDEXABLE insertion_done: item (k) = v end prune (v: INTEGER) is -- Remove one occurrence of v if any. -- Not applicable here. -- (from INTEGER_INTERVAL) require -- from COLLECTION prunable: prunable do ensure then -- from SET removed_count_change: old has (v) implies (count = old count - 1) not_removed_no_count_change: not old has (v) implies (count = old count) item_deleted: not has (v) end feature {NONE} -- Implementation on_change is -- Called when interval changes. do if opo_change_actions /= void then opo_change_actions.call (void) end end opo_change_actions: ACTION_SEQUENCE [TUPLE] -- Once per object implementation for change_actions feature {INTEGER_INTERVAL} -- Implementation lower_internal: INTEGER -- See `lower`. -- (from INTEGER_INTERVAL) upper_internal: INTEGER -- See `upper`. -- (from INTEGER_INTERVAL) feature -- Event handling change_actions: ACTION_SEQUENCE [TUPLE] is -- Actions performed when interval changes. do if opo_change_actions = void then create opo_change_actions end Result := opo_change_actions ensure not_void: Result /= void end feature -- Iteration exists (condition: FUNCTION [ANY, TUPLE [INTEGER], BOOLEAN]): BOOLEAN is -- Does at least one of  interval's values -- satisfy condition? -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined local i: INTEGER do from i := lower until i > upper or else condition.item ([i]) loop i := i + 1 end Result := (i <= upper) ensure -- from INTEGER_INTERVAL consistent_with_count: Result = (hold_count (condition) > 0) end exists1 (condition: FUNCTION [ANY, TUPLE [INTEGER], BOOLEAN]): BOOLEAN is -- Does exactly one of  interval's values -- satisfy condition? -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined do Result := (hold_count (condition) = 1) ensure -- from INTEGER_INTERVAL consistent_with_count: Result = (hold_count (condition) = 1) end for_all (condition: FUNCTION [ANY, TUPLE [INTEGER], BOOLEAN]): BOOLEAN is -- Do all interval's values satisfy condition? -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined local i: INTEGER do from Result := True i := lower until (i > upper) or else (not condition.item ([i])) loop i := i + 1 end Result := (i > upper) ensure -- from INTEGER_INTERVAL consistent_with_count: Result = (hold_count (condition) = count) end hold_count (condition: FUNCTION [ANY, TUPLE [INTEGER], BOOLEAN]): INTEGER is -- Number of  interval's values that -- satisfy condition -- (from INTEGER_INTERVAL) require -- from INTEGER_INTERVAL finite: upper_defined and lower_defined local i: INTEGER do from i := lower until i > upper loop if condition.item ([i]) then Result := Result + 1 end i := i + 1 end ensure -- from INTEGER_INTERVAL non_negative: Result >= 0 end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from INTEGER_INTERVAL 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 -- from RESIZABLE increase_by_at_least_one: minimal_increase >= 1 -- from BOUNDED valid_count: count <= capacity full_definition: full = (count = capacity) -- from FINITE empty_definition: is_empty = (count = 0) non_negative_count: count >= 0 -- from 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 -- class ACTIVE_INTEGER_INTERVAL
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

-- Generated by ISE Eiffel --
For more details: www.eiffel.com