indexing
	description: "Objects that are able to iterate over traversable structures, on which they can perform repeated actions and tests according to a number of predefined control structures such as ``if%'%', ``until%'%' and others."
	names: iterators, iteration

deferred class interface
	ITERATOR [G]

feature -- Status report

	invariant_value: BOOLEAN
			-- Is the invariant satisfied?
			-- (Redefinitions of this feature will usually involve
			-- target; if so, make sure that the result is defined
			-- when target = Void.)
		require
			traversable_exists: target /= void

	item_test (v: G): BOOLEAN
			-- Test to be applied to item v
			-- (default: false)

	target: TRAVERSABLE [G]
			-- The structure to which iteration features will apply

	test: BOOLEAN
			-- Test to be applied to item at current position in target
			-- (default: value of item_test on item)
		require
			traversable_exists: target /= void;
			not_off: not target.off
		ensure
			not_off: not target.off
	
feature -- Status setting

	set (s: like target)
			-- Make s the new target of iterations.
		require
			s /= void
		ensure
			target = s;
			target /= void
	
feature -- Cursor movement

	do_all
			-- Apply action to every item of target.
		require
			traversable_exists: target /= void

	do_if
			-- Apply action to every item of target satisfying test.
		require
			traversable_exists: target /= void

	do_until
			-- Apply action to every item of target up to
			-- and including first one satisfying test.
			-- (Apply to full list if no item satisfies test).
		require
			traversable_exists: target /= void

	do_while
			-- Apply action to every item of target up to
			-- and including first one not satisfying test.
			-- (Apply to full list if all items satisfy test).

	exists: BOOLEAN
			-- Is test true for at least one item of target?
		require
			traversable_exists: target /= void

	forall: BOOLEAN
			-- Is test true for all items of target?
		require
			traversable_exists: target /= void

	until_do
			-- Apply action to every item of target up to
			-- but excluding first one satisfying test.
			-- (Apply to full list if no items satisfy test.)
		require
			traversable_exists: target /= void

	while_do
			-- Apply action to every item of target up to
			-- but excluding first one satisfying not test.
			-- (Apply to full list if all items satisfy test.)
		require
			traversable_exists: target /= void
	
feature -- Element change

	action
			-- Action to be applied to item at current position
			-- in target (default: item_action on that item).
			-- For iterators to work properly, redefined versions of
			-- this feature should not change the traversable's
			-- structure.
		require
			traversable_exists: target /= void;
			not_off: not target.off;
			invariant_satisfied: invariant_value
		ensure
			not_off: not target.off;
			invariant_satisfied: invariant_value

	item_action (v: G)
			-- Action to be applied to item v
			-- (Default: do nothing.)
	
invariant

		-- from GENERAL
	reflexive_equality: standard_is_equal (Current);
	reflexive_conformance: conforms_to (Current);

end -- class ITERATOR