Automatic generation produced by ISE Eiffel
note description: "Set based on implementation of HASH_TABLE for fast lookup." legal: "See notice at end of class." status: "See notice at end of class." date: "$Date: 2023-07-12 09:05:56 -0800 (Wed, 12 Jul 2023) $" revision: "$Revision: 107135 $" class interface SEARCH_TABLE [H -> HASHABLE] create make (n: INTEGER_32) -- Allocate hash table for at least n items using ~ for comparison. -- The table will be resized automatically if more than n items are inserted. require n_non_negative: n >= 0 ensure capacity_big_enough: capacity >= n make_map (n: INTEGER_32) -- Allocate hash table for at least n items using = for comparison. -- The table will be resized automatically if more than n items are inserted. require n_non_negative: n >= 0 ensure capacity_big_enough: capacity >= n is_map: is_map make_with_key_tester (n: INTEGER_32; a_key_tester: detachable EQUALITY_TESTER [H]) -- Allocate hash table for at least n items with a_key_tester to compare keys. -- If a_key_tester is void, it uses ~ for comparison. -- The table will be resized automatically if more than n items are inserted. require n_non_negative: n >= 0 ensure capacity_big_enough: capacity >= n count_set: count = 0 feature -- Access generating_type: TYPE [detachable SEARCH_TABLE [H]] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) ensure -- from ANY generating_type_not_void: Result /= Void generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty feature -- Comparison frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) disjoint (other: like Current): BOOLEAN -- Is Current and other disjoint on their keys? -- Use `same_keys` for comparison. frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) frozen is_deep_equal alias "≡≡≡" (other: SEARCH_TABLE [H]): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) is_equal (other: like Current): BOOLEAN -- Does table contain the same information as other? require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result same_keys (a_search_key, a_key: H): BOOLEAN -- Does a_search_key equal to a_key? require valid_search_key: valid_key (a_search_key) valid_key: valid_key (a_key) frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) frozen standard_is_equal alias "≜" (other: SEARCH_TABLE [H]): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) feature -- Resizing resize (n: INTEGER_32) -- Resize table to accommodate n elements. require n_non_negative: n >= 0 n_greater_than_count: n >= count feature -- Conversion linear_representation: ARRAYED_LIST [H] -- Representation as a linear structure. -- (Order is same as original order of insertion.) ensure then result_exists: Result /= Void good_count: Result.count = count feature -- Duplication copy (other: like Current) -- Re-initialize from other. require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: SEARCH_TABLE [H]) -- Effect equivalent to that of: -- `copy` (other . `deep_twin`) -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY deep_equal: deep_equal (Current, other) frozen deep_twin: SEARCH_TABLE [H] -- New object structure recursively duplicated from Current. -- (from ANY) ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) frozen standard_copy (other: SEARCH_TABLE [H]) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_standard_equal: standard_is_equal (other) frozen standard_twin: SEARCH_TABLE [H] -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) frozen twin: SEARCH_TABLE [H] -- New object equal to Current -- `twin` calls `copy`; to change copying/twinning semantics, redefine `copy`. -- (from ANY) ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current feature -- Basic operations frozen default: detachable SEARCH_TABLE [H] -- Default value of object's type -- (from ANY) frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.`default` for -- some p of type POINTER.) -- (from ANY) ensure -- from ANY instance_free: class default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) frozen do_nothing -- Execute a null action. -- (from ANY) ensure -- from ANY instance_free: class feature -- Access and queries found: BOOLEAN -- Did last operation find the item sought? found_item: detachable H -- Item found during a search with `has` to reduce the number of -- search for clients. go_to (c: like cursor) -- Move to position c. require valid_cursor: valid_cursor (c) has (key: H): BOOLEAN -- Is access_key currently used? -- (Shallow equality.) require valid_key: valid_key (key) is_empty: BOOLEAN -- Is structure empty? item (key: H): detachable H -- Item associated with key, if present -- otherwise default value of type G. require valid_key: valid_key (key) key_at (n: INTEGER_32): detachable H -- Key corresponding to entry n. key_tester: detachable EQUALITY_TESTER [H] -- Tester used for comparing keys. new_cursor: SEARCH_TABLE_ITERATION_CURSOR [H] -- Fresh cursor associated with current structure ensure -- from ITERABLE result_attached: Result /= Void search (key: H) -- Search for item of key key. -- If found, set `found` to True, and set -- `found_item` to item associated with key. ensure item_if_found: found implies (found_item = content.item (position)) feature -- Assertion check valid_cursor (c: like cursor): BOOLEAN -- Can cursor be moved to position c? valid_key (k: detachable H): BOOLEAN -- Is k a valid key? ensure definition: Result implies k /= Void feature -- Insertion, deletion change_key (new_key: H; old_key: H) -- If table contains an item at old_key, -- replace its key by new_key. -- Set `control` to `changed`, `conflict` or `not_found_constant`. require valid_keys: valid_key (new_key) and valid_key (old_key) ensure changed: control = Changed implies not has (old_key) clear_all -- Reset all items to default values. -- Was declared in {SEARCH_TABLE} as synonym of `wipe_out`. force (key: H) -- If key is present, replace key -- if not, insert key key. -- Set `control` to `inserted`. require valid_key (key) ensure then insertion_done: pure_item (key) = key merge (other: SEARCH_TABLE [H]) -- Merge two search_tables. require other_not_void: other /= Void prune (key: H) -- Remove item associated with key, if present. -- Set `control` to `removed` or `not_found_constant`. -- Was declared in {SEARCH_TABLE} as synonym of `remove`. require valid_key: valid_key (key) ensure not_has: not has (key) put (key: H) -- Attempt to insert with key. -- Set `control` to `inserted` or `conflict`. -- No insertion if conflict. require valid_key (key) ensure then insertion_done: control = Inserted implies pure_item (key) = key remove (key: H) -- Remove item associated with key, if present. -- Set `control` to `removed` or `not_found_constant`. -- Was declared in {SEARCH_TABLE} as synonym of `prune`. require valid_key: valid_key (key) ensure not_has: not has (key) wipe_out -- Reset all items to default values. -- Was declared in {SEARCH_TABLE} as synonym of `clear_all`. feature -- Iteration after: BOOLEAN -- Is the iteration cursor off? -- Was declared in {SEARCH_TABLE} as synonym of `off`. cursor: INTEGER_32 -- Cursor. forth -- Advance cursor to next occupied position, -- or `off` if no such position remains. require not_off: not off item_for_iteration: H -- Item at cursor position. -- Was declared in {SEARCH_TABLE} as synonym of `key_for_iteration`. require not_off: not after key_for_iteration: H -- Item at cursor position. -- Was declared in {SEARCH_TABLE} as synonym of `item_for_iteration`. require not_off: not after next_iteration_position (a_position: like iteration_position): like iteration_position -- Given an iteration position a_position, compute the next one. off: BOOLEAN -- Is the iteration cursor off? -- Was declared in {SEARCH_TABLE} as synonym of `after`. start -- Iteration initialization. feature -- Number of elements count: INTEGER_32 -- Number of items actually inserted in Current. feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) ensure -- from ANY instance_free: class io_not_void: Result /= Void out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY out_not_void: Result /= Void print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) ensure -- from ANY instance_free: class frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY tagged_out_not_void: Result /= Void feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void invariant count_big_enough: 0 <= count -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2023, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class SEARCH_TABLE -- Generated by Eiffel Studio --
For more details: eiffel.org