INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

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. "
title: "EiffelBase: library of reusable components for Eiffel. ", "Based on EiffelBase library for ISE Eiffel, ", "used with permission. "
project: "EiffelBase Library"
copyright: "(c) 1986-1997 Interactive Software Engineering Inc. ", "Modifications and extensions: ", "(c) 1997 Object Tools ", "All rights reserved. Duplication and distribution prohibited", "May be used only with Visual Eiffel under terms of user ", "license "
key: iterators, iteration
cluster: eiffelbase
deferred class ITERATOR [G]
feature -- Status report

target: TRAVERSABLE [G]

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

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

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
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').

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

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

exists: BOOLEAN
-- Is `test' true for at least one item of `target'?
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.)
end -- class ITERATOR

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES