Automatic generation produced by ISE Eiffel
note description: "Cursor trees with a recursive structure" library: "Free implementation of ELKS library" legal: "See notice at end of class." status: "See notice at end of class." names: recursive_cursor_tree, cursor_tree, tree access: cursor, membership representation: recursive contents: generic date: "$Date: 2018-12-15 09:06:16 -0900 (Sat, 15 Dec 2018) $" revision: "$Revision: 102608 $" deferred class interface RECURSIVE_CURSOR_TREE [G -> ] feature -- Initialization default_create -- Process instances of classes with no creation clause. -- (Default: do nothing.) -- (from ANY) feature -- Access child_item (i: INTEGER_32): G -- Item in i-th child -- (from CURSOR_TREE) require -- from CURSOR_TREE argument_within_bounds: i >= 1 and then i <= arity not_off: not off cursor: RECURSIVE_TREE_CURSOR [G] -- Current cursor position ensure -- from CURSOR_STRUCTURE cursor_not_void: Result /= Void generating_type: TYPE [detachable RECURSIVE_CURSOR_TREE [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 has (v: G): BOOLEAN -- Does structure include an occurrence of v? -- (Reference or object equality, -- based on `object_comparison`.) -- (from CURSOR_TREE) linear_has (v: like item): BOOLEAN -- Does structure include an occurrence of v? -- (Reference or object equality, -- based on `object_comparison`.) -- (from LINEAR) ensure -- from CONTAINER not_found_in_empty: Result implies not is_empty index_of (v: like item; i: INTEGER_32): INTEGER_32 -- Index of i-th occurrence of v. -- 0 if none. -- (Reference or object equality, -- based on `object_comparison`.) -- (from LINEAR) require -- from LINEAR positive_occurrences: i > 0 ensure -- from LINEAR non_negative_result: Result >= 0 item: G -- Item at cursor position require -- from TRAVERSABLE not_off: not off require -- from ACTIVE readable: readable item_for_iteration: G -- Item at current position -- (from LINEAR) require -- from LINEAR not_off: not off new_cursor: ITERATION_CURSOR [G] -- Fresh cursor associated with current structure -- (from ITERABLE) ensure -- from ITERABLE result_attached: Result /= Void occurrences (v: G): INTEGER_32 -- Number of times v appears in structure -- (Reference or object equality, -- based on `object_comparison`.) -- (from CURSOR_TREE) linear_occurrences (v: like item): INTEGER_32 -- Number of times v appears. -- (Reference or object equality, -- based on `object_comparison`.) -- (from LINEAR) parent_item: G -- Item in parent. -- (from CURSOR_TREE) require -- from CURSOR_TREE not_on_root: not is_root search (v: like item) -- Move to first position (at or after current -- position) where `item` and v are equal. -- (Reference or object equality, -- based on `object_comparison`.) -- If no such position ensure that `exhausted` will be true. -- (from LINEAR) ensure -- from LINEAR object_found: (not exhausted and object_comparison) implies v ~ item item_found: (not exhausted and not object_comparison) implies v = item feature -- Measurement arity: INTEGER_32 -- Number of children of active node. -- If cursor is `above`, 0 if tree is empty, 1 otherwise. require -- from HIERARCHICAL not_off: not off require else valid_cursor: not off or else above breadth: INTEGER_32 -- Breadth of current level -- (from CURSOR_TREE) count: INTEGER_32 -- Number of items in the tree depth: INTEGER_32 -- Depth of the tree -- (from CURSOR_TREE) estimated_count_of (other: ITERABLE [G]): INTEGER_32 -- Estimated number of elements in other. -- (from CONTAINER) ensure -- from CONTAINER instance_free: class non_negative_result: Result >= 0 level: INTEGER_32 -- Level of current node in tree -- (Root is on level 1) -- (from CURSOR_TREE) 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) 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: RECURSIVE_CURSOR_TREE [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: RECURSIVE_CURSOR_TREE [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: 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: RECURSIVE_CURSOR_TREE [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 above: BOOLEAN -- Is there no valid cursor position above cursor? after: BOOLEAN -- Is there no valid cursor position to the right of cursor? before: BOOLEAN -- Is there no valid cursor position to the left of cursor? below: BOOLEAN -- Is there no valid cursor position below cursor? -- (from CURSOR_TREE) changeable_comparison_criterion: BOOLEAN -- May `object_comparison` be changed? -- (Answer: yes by default.) -- (from CONTAINER) 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 exhausted: BOOLEAN -- Has structure been completely explored? -- (from LINEAR) ensure -- from LINEAR exhausted_when_off: off implies Result extendible: BOOLEAN -- May new items be added on current level? require -- from COLLECTION True is_empty: BOOLEAN -- Is the tree empty? is_inserted (v: G): BOOLEAN -- 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) is_leaf: BOOLEAN -- Is cursor on a leaf? -- (from CURSOR_TREE) is_root: BOOLEAN -- Is cursor on tree root? isfirst: BOOLEAN -- Is cursor on first sibling? islast: BOOLEAN -- Is cursor on last sibling? object_comparison: BOOLEAN -- Must search operations use `equal` rather than = -- for comparing references? (Default: no, use =.) -- (from CONTAINER) off: BOOLEAN -- Is there no current item? -- (True if `is_empty`) -- (from CURSOR_TREE) linear_off: BOOLEAN -- Is there no current item? -- (from LINEAR) prunable: BOOLEAN -- May items be removed? -- (from COLLECTION) readable: BOOLEAN -- Is there a current item that may be read? -- (from CURSOR_TREE) replaceable: BOOLEAN -- Can current item be replaced? -- (from ACTIVE) 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_cursor (p: CURSOR): BOOLEAN -- Can the cursor be moved to position p? valid_cursor_index (i: INTEGER_32): BOOLEAN -- Can cursor be moved to i-th child? -- 0 is before and `arity` + 1 is after. -- (from CURSOR_TREE) writable: BOOLEAN -- Is there a current item that may be modified? -- (from CURSOR_TREE) feature -- Status setting compare_objects -- Ensure that future search operations will use `equal` -- rather than = for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion: changeable_comparison_criterion ensure -- from CONTAINER object_comparison compare_references -- Ensure that future search operations will use = -- rather than `equal` for comparing references. -- (from CONTAINER) require -- from CONTAINER changeable_comparison_criterion: changeable_comparison_criterion ensure -- from CONTAINER reference_comparison: not object_comparison feature -- Cursor movement back -- Move cursor one position backward. breadth_forth -- Move cursor to next position in breadth-first order. -- If the active node is the last in -- breadth-first order, the cursor ends up `off`. -- (from CURSOR_TREE) require -- from CURSOR_TREE not_off: not off down (i: INTEGER_32) -- Move cursor one level downward: -- to i-th child if there is one, -- or `after` if i = `arity` + 1, -- or `before` if i = 0. require -- from HIERARCHICAL not_off: not off argument_within_bounds: i >= 1 and i <= arity require else -- from CURSOR_TREE not_before: not before not_after: not after not_below: not below valid_cursor_index: (above and i = 0) or else valid_cursor_index (i) ensure then -- from CURSOR_TREE gone_before: (i = 0) implies before forth -- Move cursor one position forward. go_last_child -- Go to the last child of current parent. -- No effect if below -- (from CURSOR_TREE) require -- from LINEAR True require else -- from CURSOR_TREE not_above: not above go_to (p: CURSOR) -- Move cursor to position p. require -- from CURSOR_STRUCTURE cursor_position_valid: valid_cursor (p) level_back -- Move cursor to previous position of current level. -- (from CURSOR_TREE) level_forth -- Move cursor to next position of current level. -- (from CURSOR_TREE) postorder_forth -- Move cursor to next position in postorder. -- If the active node is the last in -- postorder, the cursor ends up `off`. -- (from CURSOR_TREE) require -- from CURSOR_TREE not_off: not off postorder_start -- Move cursor to first position in postorder. -- Leave cursor off if tree is empty. -- (from CURSOR_TREE) preorder_forth -- Move cursor to next position in preorder. -- If the active node is the last in -- preorder, the cursor ends up `off`. -- (from CURSOR_TREE) require -- from LINEAR not_after: not after start -- Move cursor to root. -- Leave cursor `off` if `is_empty`. -- (from CURSOR_TREE) require -- from TRAVERSABLE True ensure then -- from CURSOR_TREE on_root_unless_empty: not is_empty implies is_root start_on_level (l: INTEGER_32) -- Move the cursor to the first position -- of the l-th level counting from root. -- (from CURSOR_TREE) require -- from CURSOR_TREE argument_within_bounds: l >= 1 and then depth >= l ensure -- from CURSOR_TREE level_expected: level = l is_first: isfirst up -- Move cursor one level upward to parent, -- or `above` if `is_root` holds. require -- from HIERARCHICAL not_off: not off require else -- from CURSOR_TREE not_above: not above ensure then -- from CURSOR_TREE not_before: not before not_after: not after not_below: not below coherency: (not old off and above) = (old is_root) feature -- Element change fill (other: CURSOR_TREE [G]) -- Fill with as many items of other -- as possible. -- The representations of other and current structure -- need not be the same. -- (from CURSOR_TREE) require -- from CURSOR_TREE is_empty: is_empty container_fill (other: CONTAINER [G]) -- 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: extendible fill_from_active (other: CURSOR_TREE [G]) -- Copy subtree of other's active node -- onto active node of current tree. -- (from CURSOR_TREE) require -- from CURSOR_TREE cursor_on_leaf: is_leaf merge_left (other: CURSOR_TREE [G]) -- Merge the items of other into current structure to -- the left of cursor position. -- (from CURSOR_TREE) require -- from CURSOR_TREE other_exists: other /= Void not_before: not before not_above: not above only_one_root: (level = 1) implies is_empty merge_right (other: CURSOR_TREE [G]) -- Merge the items of other into current structure to -- the right of cursor position. -- (from CURSOR_TREE) require -- from CURSOR_TREE other_exists: other /= Void not_after: not after not_above: not above only_one_root: (level = 1) implies is_empty put (v: G) -- Put v at cursor position. -- (Synonym for `replace`) -- (from CURSOR_TREE) require -- from COLLECTION extendible: extendible ensure -- from COLLECTION item_inserted: is_inserted (v) put_left (v: G) -- Add v to the left of cursor position. -- (from CURSOR_TREE) require -- from CURSOR_TREE not_before: not before not_above: not above only_one_root: (level = 1) implies is_empty put_right (v: G) -- Add v to the right of cursor position. -- (from CURSOR_TREE) require -- from CURSOR_TREE not_after: not after not_above: not above only_one_root: (level = 1) implies is_empty replace (v: G) -- Replace current item by v. require -- from ACTIVE writable: writable replaceable: replaceable ensure -- from ACTIVE item_replaced: item = v feature -- Removal prune_all (v: G) -- Remove all occurrences of v. -- (Reference or object equality, -- based on `object_comparison`.) -- (from COLLECTION) require -- from COLLECTION prunable: prunable ensure -- from COLLECTION no_more_occurrences: not has (v) remove -- Remove node at cursor position -- (and consequently the corresponding -- subtree). Cursor moved up one level. require -- from ACTIVE prunable: prunable writable: writable ensure then not_off_unless_empty: is_empty or else not off wipe_out -- Remove all items. require -- from COLLECTION prunable: prunable ensure -- from COLLECTION wiped_out: is_empty ensure then cursor_above: above feature -- Conversion linear_representation: LINEAR [G] -- Representation as a linear structure -- (from LINEAR) require -- from CONTAINER True feature -- Duplication child_tree (i: INTEGER_32): RECURSIVE_CURSOR_TREE [G] -- Subtree rooted at i-th child -- (from CURSOR_TREE) require -- from CURSOR_TREE argument_within_bounds: i >= 1 and then i <= arity not_off: not off copy (other: RECURSIVE_CURSOR_TREE [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: RECURSIVE_CURSOR_TREE [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: RECURSIVE_CURSOR_TREE [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) parent_tree: RECURSIVE_CURSOR_TREE [G] -- Subtree rooted at parent -- (from CURSOR_TREE) require -- from CURSOR_TREE not_on_root: not is_root not_off: not off frozen standard_copy (other: RECURSIVE_CURSOR_TREE [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: RECURSIVE_CURSOR_TREE [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) subtree: RECURSIVE_CURSOR_TREE [G] -- Subtree rooted at current node -- (from CURSOR_TREE) require -- from CURSOR_TREE not_off: not off frozen twin: RECURSIVE_CURSOR_TREE [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: detachable RECURSIVE_CURSOR_TREE [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 -- Inapplicable prune (v: G) -- Remove item v. -- (from CURSOR_TREE) require -- from COLLECTION prunable: prunable feature -- Insert element extend (v: G) -- Add v after last child. -- Make v the first_child if `below` and place -- cursor `before`. require -- from COLLECTION extendible: extendible ensure -- from COLLECTION item_inserted: is_inserted (v) feature -- Iteration do_all (action: PROCEDURE [G]) -- Apply action to every item. -- Semantics not guaranteed if action changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from TRAVERSABLE) require -- from TRAVERSABLE action_exists: action /= Void linear_do_all (action: PROCEDURE [G]) -- Apply action to every item. -- Semantics not guaranteed if action changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE action_exists: action /= Void do_if (action: PROCEDURE [G]; test: FUNCTION [G, BOOLEAN]) -- Apply action to every item that satisfies test. -- Semantics not guaranteed if action or test changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from TRAVERSABLE) require -- from TRAVERSABLE action_exists: action /= Void test_exists: test /= Void linear_do_if (action: PROCEDURE [G]; test: FUNCTION [G, BOOLEAN]) -- Apply action to every item that satisfies test. -- Semantics not guaranteed if action or test changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE action_exists: action /= Void test_exists: test /= Void linear_for_all (test: FUNCTION [G, BOOLEAN]): BOOLEAN -- Is test true for all items? -- Semantics not guaranteed if test changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE test_exists: test /= Void ensure then -- from LINEAR empty: is_empty implies Result for_all (test: FUNCTION [G, BOOLEAN]): BOOLEAN -- Is test true for all items? -- (from TRAVERSABLE) require -- from TRAVERSABLE test_exists: test /= Void there_exists (test: FUNCTION [G, BOOLEAN]): BOOLEAN -- Is test true for at least one item? -- (from TRAVERSABLE) require -- from TRAVERSABLE test_exists: test /= Void linear_there_exists (test: FUNCTION [G, BOOLEAN]): BOOLEAN -- Is test true for at least one item? -- Semantics not guaranteed if test changes the structure; -- in such a case, apply iterator to clone of structure instead. -- (from LINEAR) require -- from TRAVERSABLE test_exists: test /= Void feature -- Not applicable index: INTEGER_32 -- Index of current position -- (from CURSOR_TREE) 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 feature -- Retrieval frozen internal_correct_mismatch -- Called from runtime to perform a proper dynamic dispatch on correct_mismatch -- from MISMATCH_CORRECTOR. -- (from ANY) invariant coherency: not above implies (attached active_parent as a and then a.child = active) -- from CURSOR_TREE non_negative_depth: depth >= 0 non_negative_breadth: breadth >= 0 is_leaf_definition: not off implies is_leaf = (arity = 0) above_property: above implies (arity <= 1) on_tree: (isfirst or islast or is_leaf or is_root) implies not off off_definition: off = after or before or above or below below_constraint: below implies ((after or before) and not above) above_constraint: above implies not (before or after or below) after_constraint: after implies not (before or above) before_constaint: before implies not (after or above) empty_below_constraint: (is_empty and (after or before)) implies below -- from HIERARCHICAL non_negative_successor_count: arity >= 0 -- from TRAVERSABLE empty_constraint: is_empty implies off -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from ACTIVE writable_constraint: writable implies readable empty_constraint: is_empty implies (not readable) and (not writable) -- from LINEAR after_constraint: after implies off note copyright: "Copyright (c) 1984-2018, 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 RECURSIVE_CURSOR_TREE -- Generated by Eiffel Studio --
For more details: eiffel.org