note
	description: "Structures whose items may be accessed sequentially, one-way"
	library: "Free implementation of ELKS library"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	names: sequential, traversing
	access: membership
	contents: generic
	date: "$Date: 2015-12-17 13:34:17 +0000 (Thu, 17 Dec 2015) $"
	revision: "$Revision: 98279 $"

deferred class interface
	LINEAR [G]

feature -- Access

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

	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.)
		require
			positive_occurrences: i > 0
		ensure
			non_negative_result: Result >= 0

	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.
		ensure
			object_found: (not exhausted and object_comparison) implies v ~ item
			item_found: (not exhausted and not object_comparison) implies v = item

	index: INTEGER_32
			-- Index of current position

	occurrences (v: like item): INTEGER_32
			-- Number of times v appears.
			-- (Reference or object equality,
			-- based on object_comparison.)

	item_for_iteration: G
			-- Item at current position
		require
			not_off: not off
	
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 -- 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.

	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.

	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.

	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.
		ensure then
			empty: is_empty implies Result
	
feature -- Conversion

	linear_representation: LINEAR [G]
			-- Representation as a linear structure
	
invariant
	after_constraint: after implies off

note
	copyright: "Copyright (c) 1984-2012, 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 LINEAR

Generated by ISE EiffelStudio