Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:
indexing description: "[ Objects that are able to iterate over cursor trees, on which they can perform repeated actions and tests according to a number of predefined control structures such as ``if'', ``until'' and others. ]" status: "See notice at end of class" names: iterators, iteration, cursor_tree_iterators, cursor_tree_iteration, tree_iterators, tree_iteration exploration: depth_first, breadth_first traversal: preorder, postorder, inorder date: "$Date: 2001-11-16 20:32:23 +0000 (Fri, 16 Nov 2001) $" revision: "$Revision: 51435 $" class CURSOR_TREE_ITERATOR [G] feature -- Initialization set (s: like target) is -- Make s the new target of iterations. -- (from LINEAR_ITERATOR) require -- from ITERATOR target_exists: s /= void do Precursor (s) create internal_item_tuple.make ensure -- from ITERATOR target = s target /= void end feature -- Access item: G is -- The item at cursor position in target -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR traversable_exists: target /= void do Result := target.item end item_tuple: TUPLE [G] is -- Tuple containing a single element, -- the item at cursor position in target'' -- (from LINEAR_ITERATOR) do internal_item_tuple.put (target.item, 1) Result := internal_item_tuple end feature -- Status report invariant_value: BOOLEAN is -- Is the invariant satisfied? -- (Redefinitions of this feature will usually involve -- target; if so, make sure that the result is defined -- when `target = Void'.) -- (from ITERATOR) do Result := True end target: CURSOR_TREE [G] -- The structure to which iteration features will apply feature -- Cursor movement breadth_forth is -- Move cursor of target to next position in breadth-first. do target.breadth_forth end breadth_start is -- Move cursor of target to root position -- (first position in preorder and breadth-first). -- Was declared in CURSOR_TREE_ITERATOR as synonym of pre_start. do target.start end exhausted: BOOLEAN is -- Is target exhausted? -- (from LINEAR_ITERATOR) do Result := target.exhausted end off: BOOLEAN is -- Is position of target off? -- (from LINEAR_ITERATOR) do Result := target.off end post_forth is -- Move cursor of target to next position in postorder. do target.postorder_forth end post_start is -- Move cursor of target to first position in postorder. do target.postorder_start end pre_forth is -- Move cursor of target to next position in preorder. do target.preorder_forth end pre_start is -- Move cursor of target to root position -- (first position in preorder and breadth-first). -- Was declared in CURSOR_TREE_ITERATOR as synonym of breadth_start. do target.start end start is -- Move to first position of target. -- (from LINEAR_ITERATOR) do target.start end feature -- Implementation internal_item_tuple: TUPLE [G] -- Field holding the last item of target -- (from LINEAR_ITERATOR) feature -- Iteration breadth_continue_for (action: PROCEDURE [ANY, TUPLE [G]]; n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_repetition: n >= 0 valid_skip: k >= 1 local i, j: INTEGER do from invariant i >= 0 and i <= n variant n - i until exhausted or else i = n loop action.call (item_tuple) i := i + 1 from j := 0 invariant j >= 0 and j <= k variant k - j until exhausted or else j = k loop pre_forth j := j + 1 end end end post_continue_for (action: PROCEDURE [ANY, TUPLE [G]]; n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_repetition: n >= 0 valid_skip: k >= 1 local i, j: INTEGER do from invariant i >= 0 and i <= n variant n - i until exhausted or else i = n loop action.call (item_tuple) i := i + 1 from j := 0 invariant j >= 0 and j <= k variant k - j until exhausted or else j = k loop pre_forth j := j + 1 end end end pre_continue_for (action: PROCEDURE [ANY, TUPLE [G]]; n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_repetition: n >= 0 valid_skip: k >= 1 local i, j: INTEGER do from invariant i >= 0 and i <= n variant n - i until exhausted or else i = n loop action.call (item_tuple) i := i + 1 from j := 0 invariant j >= 0 and j <= k variant k - j until exhausted or else j = k loop pre_forth j := j + 1 end end end post_continue_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target -- satisfying: test equals to b -- (from the current position of target). -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else (b = test.item (item_tuple)) loop pre_forth end ensure then -- from LINEAR_ITERATOR found: not exhausted = (b = test.item (item_tuple)) end breadth_continue_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target -- satisfying: test equals to b -- (from the current position of target). -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else (b = test.item (item_tuple)) loop pre_forth end ensure then -- from LINEAR_ITERATOR found: not exhausted = (b = test.item (item_tuple)) end pre_continue_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target -- satisfying: test equals to b -- (from the current position of target). -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else (b = test.item (item_tuple)) loop pre_forth end ensure then -- from LINEAR_ITERATOR found: not exhausted = (b = test.item (item_tuple)) end post_continue_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from the current position of target). -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end breadth_continue_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from the current position of target). -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end pre_continue_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from the current position of target). -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end pre_continue_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test -- (from the current position of target). -- (from LINEAR_ITERATOR) require else -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else not test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end breadth_continue_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test -- (from the current position of target). -- (from LINEAR_ITERATOR) require else -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else not test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end post_continue_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test -- (from the current position of target). -- (from LINEAR_ITERATOR) require else -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from if not exhausted then action.call (item_tuple) end invariant invariant_value until exhausted or else not test.item (item_tuple) loop pre_forth if not exhausted then action.call (item_tuple) end end ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end breadth_do_all (action: PROCEDURE [ANY, TUPLE [G]]) is -- Apply action to every item of target. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void do target.linear_do_all (action) end post_do_all (action: PROCEDURE [ANY, TUPLE [G]]) is -- Apply action to every item of target. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void do target.linear_do_all (action) end pre_do_all (action: PROCEDURE [ANY, TUPLE [G]]) is -- Apply action to every item of target. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void do target.linear_do_all (action) end pre_do_for (action: PROCEDURE [ANY, TUPLE [G]]; i, n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible, starting from i-th. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_start: i >= 1 valid_repetition: n >= 0 valid_skip: k >= 1 local j: INTEGER do from start j := 1 invariant j >= 1 and j <= i variant i - j until exhausted or else j = i loop pre_forth j := j + 1 end pre_continue_for (action, n, k) end post_do_for (action: PROCEDURE [ANY, TUPLE [G]]; i, n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible, starting from i-th. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_start: i >= 1 valid_repetition: n >= 0 valid_skip: k >= 1 local j: INTEGER do from start j := 1 invariant j >= 1 and j <= i variant i - j until exhausted or else j = i loop pre_forth j := j + 1 end pre_continue_for (action, n, k) end breadth_do_for (action: PROCEDURE [ANY, TUPLE [G]]; i, n, k: INTEGER) is -- Apply action to every k-th item, -- n times if possible, starting from i-th. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR valid_start: i >= 1 valid_repetition: n >= 0 valid_skip: k >= 1 local j: INTEGER do from start j := 1 invariant j >= 1 and j <= i variant i - j until exhausted or else j = i loop pre_forth j := j + 1 end pre_continue_for (action, n, k) end post_do_if (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target satisfying test. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do target.linear_do_if (action, test) end pre_do_if (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target satisfying test. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do target.linear_do_if (action, test) end breadth_do_if (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target satisfying test. -- (from ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do target.linear_do_if (action, test) end breadth_do_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_until (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end pre_do_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_until (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end post_do_until (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one satisfying test. -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_until (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end pre_do_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test. -- (from the start of target) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_while (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end breadth_do_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test. -- (from the start of target) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_while (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end post_do_while (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- and including first one not satisfying test. -- (from the start of target) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_continue_while (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end pre_for_all (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- all items of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, False) Result := exhausted end post_for_all (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- all items of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, False) Result := exhausted end breadth_for_all (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- all items of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, False) Result := exhausted end post_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target for which test -- has the same value as b (both true or both false). -- (from LINEAR_ITERATOR) do start pre_continue_search (test, b) end breadth_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target for which test -- has the same value as b (both true or both false). -- (from LINEAR_ITERATOR) do start pre_continue_search (test, b) end pre_search (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]; b: BOOLEAN) is -- Search the first item of target for which test -- has the same value as b (both true or both false). -- (from LINEAR_ITERATOR) do start pre_continue_search (test, b) end post_there_exists (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- at least one item of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, True) Result := not exhausted end breadth_there_exists (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- at least one item of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, True) Result := not exhausted end pre_there_exists (test: FUNCTION [ANY, TUPLE [G], BOOLEAN]): BOOLEAN is -- Does test return true for -- at least one item of target? -- (from LINEAR_ITERATOR) require -- from ITERATOR test_exists: test /= void do pre_search (test, True) Result := not exhausted end until_continue (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target from current -- position, up to but excluding first one satisfying test. -- (from LINEAR_ITERATOR) require -- from LINEAR_ITERATOR invariant_satisfied: invariant_value do from invariant invariant_value until exhausted or else test.item (item_tuple) loop action.call ([item]) pre_forth end ensure -- from LINEAR_ITERATOR achieved: exhausted or else test.item (item_tuple) invariant_satisfied: invariant_value end breadth_until_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one satisfying test. -- (Apply to full list if no item satisfies test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start until_continue (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end pre_until_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one satisfying test. -- (Apply to full list if no item satisfies test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start until_continue (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end post_until_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one satisfying test. -- (Apply to full list if no item satisfies test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start until_continue (action, test) ensure then -- from LINEAR_ITERATOR achieved: not exhausted implies test.item (item_tuple) end breadth_while_continue (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else not test.item (item_tuple) loop action.call (item_tuple) pre_forth end ensure -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end pre_while_continue (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else not test.item (item_tuple) loop action.call (item_tuple) pre_forth end ensure -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end post_while_continue (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (from LINEAR_ITERATOR) do from invariant invariant_value until exhausted or else not test.item (item_tuple) loop action.call (item_tuple) pre_forth end ensure -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end breadth_while_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (Apply to full list if all items satisfy test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_while_continue (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end pre_while_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (Apply to full list if all items satisfy test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_while_continue (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end post_while_do (action: PROCEDURE [ANY, TUPLE [G]]; test: FUNCTION [ANY, TUPLE [G], BOOLEAN]) is -- Apply action to every item of target up to -- but excluding first one not satisfying test. -- (Apply to full list if all items satisfy test.) -- (from LINEAR_ITERATOR) require -- from ITERATOR action_exists: action /= void test_exists: test /= void do start pre_while_continue (action, test) ensure then -- from LINEAR_ITERATOR finished: not exhausted implies not test.item (item_tuple) end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) -- from LINEAR_ITERATOR target_exists: target /= void item_tuple_exists: item_tuple /= void internal_item_tuple_exists: internal_item_tuple /= void -- from ITERATOR traversable_exists: target /= 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 CURSOR_TREE_ITERATOR
Classes Clusters Cluster hierarchy Chart Relations Text Flat Contracts Flat contracts Go to:

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