INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Structures whose items may be accessed sequentially, one-way"
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: sequential, traversing
cluster: eiffelbase
deferred class LINEAR [G]
inherit

TRAVERSABLE [G]
end
feature -- Access

has (v: G): BOOLEAN
-- Does structure include an occurrence of `v'?
-- (Reference or object equality,
-- based on `object_comparison'.)

index_of (v: G; i: INTEGER): INTEGER
-- Index of `i'-th occurrence of `v'.
-- 0 if none.
-- (Reference or object equality,
-- based on `object_comparison'.)
require
positive_occurrences: i > 0
ensure
non_negative_result: Result >= 0

search (v: G)
-- 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.
ensure
object_found: (not exhausted and then object_comparison and then v /= void and then item /= void) implies v.is_equal (item)
item_found: (not exhausted and not object_comparison) implies v = item

index: INTEGER
-- Index of current position

occurrences (v: G): INTEGER
-- Number of times `v' appears.
-- (Reference or object equality,
-- based on `object_comparison'.)
feature -- Status report

exhausted: BOOLEAN
-- Has structure been completely explored?
ensure
exhausted_when_off: off implies Result

after: BOOLEAN
-- Is there no valid position to the right of current one?

off: BOOLEAN
-- Is there no current item?
feature -- Cursor movement

finish
-- Move to last position.

forth
-- Move to next position; if no next position,
-- ensure that `exhausted' will be true.
require
not_after: not after
feature -- Conversion

linear_representation: LINEAR [G]
-- Representation as a linear structure
invariant

after_constraint: after implies off
end -- class LINEAR

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES