Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:
note description: "Tree Node for a 2-3-4 balanced tree" legal: "See notice at end of class." status: "See notice at end of class." author: "Christophe Bonnard" revised_by: "Alexander Kogtenkov" date: "$Date: 2021-04-06 02:22:01 -0800 (Tue, 06 Apr 2021) $" revision: "$Revision: 105267 $" class interface TREE_NODE [G -> ] create make -- Initialize as a blank tree. make_with_child (first_child: like Current) -- Initialize Current with a first_child. -- first_child's parent is changed as a side effect. feature -- Initialization make -- Initialize as a blank tree. make_with_child (first_child: like Current) -- Initialize Current with a first_child. -- first_child's parent is changed as a side effect. feature -- Access children: ARRAY [like Current] -- children of Current first_item: like item -- first key of a tree -- goes much faster than "item (1)" require has_children: not is_leaf implies children [1] /= Void generating_type: TYPE [TREE_NODE [G]] -- 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 item (i: INTEGER_32): TREE_KEY [G] -- ith key of the tree, if Current was the root node. require i_big_enough: i >= 1 i_small_enough: i < keys_plus_one ensure final_result_good: is_root implies (Result.number = i) keys: ARRAY [like item] -- keys contained by Current last_item: like item -- last key of a tree -- goes much faster than "item (keys_plus_one - 1)" parent: like Current -- parent of Current -- Void if Current is a root. feature -- Measurement arity: INTEGER_32 -- Number of children keys_plus_one: INTEGER_32 -- Total number of keys of the node and its children, plus one. feature -- Comparison frozen deep_equal (a: 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) frozen equal (a: 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: TREE_NODE [G]): 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: TREE_NODE [G]): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result frozen standard_equal (a: 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: TREE_NODE [G]): 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 is_leaf: BOOLEAN -- Is Current a leaf? is_root: BOOLEAN -- Is Current the root node of the tree? keys_before_child (i: INTEGER_32): INTEGER_32 -- Number of keys in the tree before child number i require i_valid: i >= 1 and then i <= children.upper pos_in_parent: INTEGER_32 -- position of node in parent. require has_a_parent: not is_root 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)) valid_key (a_key: like item): BOOLEAN -- Is a_key valid as in current node? feature -- Element change insert_first (key: like item) -- Insert key in first position of the tree. require has_children: not is_leaf implies children [1] /= Void insert_key_and_left_child (key: like item; node: like Current; pos: INTEGER_32) -- insert key at position pos, and node at left of key -- (so node will be @pos) insert_key_and_right_child (key: like item; node: like Current; pos: INTEGER_32) -- insert key at position pos, and node at right of key -- (so node will be @pos+1) require key_not_void: key /= Void insert_last (key: like item) -- Insert key in last position of the tree. require has_last_item: not is_leaf implies children [arity] /= Void set_parent (par: like Current) -- make par the parent of Current feature -- Removal delete (pos: INTEGER_32) -- delete key in position pos in the node. feature -- Resizing Child_number: INTEGER_32 = 5 -- Maximum number of children feature -- Transformation balance_heavy_node -- rebalance a heavy node (splitting it) balance_light_node -- rebalance a light node (by key migration or merging) balance_light_root -- Rebalance the root node by merging it with its children. require current_is_root: is_root several_level_tree: not is_leaf node_and_children_can_merge: (arity < 3) and then (attached children.item (1) as l_chi_1 and then attached children.item (2) as l_chi_2 and then (l_chi_1.arity + l_chi_2.arity < 6)) feature -- Conversion merge_left (other: like Current) -- Add other at the left of Current. merge_right (other: like Current) -- Add other at the right of Current. require other_not_void: other /= Void other_has_children: children.valid_index (1) feature -- Duplication copy (other: TREE_NODE [G]) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: TREE_NODE [G]) -- 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: TREE_NODE [G] -- 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: TREE_NODE [G]) -- 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: TREE_NODE [G] -- 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: TREE_NODE [G] -- 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: TREE_NODE [G] -- 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 -- 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: 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 -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2021, 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 TREE_NODE
Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:

-- Generated by Eiffel Studio --
For more details: eiffel.org