note
	description: "Circular chains, without commitment to a particular representation"
	library: "Free implementation of ELKS library"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	names: circular, ring, sequence
	access: index, cursor, membership
	contents: generic
	date: "$Date: 2018-12-15 18:06:16 +0000 (Sat, 15 Dec 2018) $"
	revision: "$Revision: 102608 $"

deferred class interface
	CIRCULAR [G]

feature -- Access

	first: G
			-- Item at position currently defined as first

	index: INTEGER_32
			-- Current cursor index, with respect to position
			-- currently defined as first

	last: like first
			-- Item at position currently defined as last
	
feature -- Status report

	valid_cursor_index (i: INTEGER_32): BOOLEAN
			-- Is i a possible cursor position?
		ensure then
			valid_cursor_index_definition: Result = ((i >= 0) and (i <= count))

	after: BOOLEAN
			-- Is there no valid cursor position to the right of cursor?
		ensure then
			empty_and_std_after: Result = (is_empty and standard_after)

	before: BOOLEAN
			-- Is there no valid cursor position to the right of cursor?
		ensure then
			empty_and_std_before: Result = (is_empty and standard_before)

	off: BOOLEAN
			-- Is there no current item?
		ensure then
			only_when_empty: Result = is_empty

	exhausted: BOOLEAN
			-- Has structure been completely explored?
	
feature -- Cursor movement

	forth
			-- Move cursor to next item, cyclically.
		ensure then
			moved_forth_at_end: (old index = count) implies (index = 1)

	back
			-- Move cursor to previous item, cyclically.

	move (i: INTEGER_32)
			-- Move cursor to i-th item from current position,
			-- cyclically.

	go_i_th (i: INTEGER_32)
			-- Move cursor to i-th position from current start, cyclically.
		require else
			index_big_enough: i >= 1
			not_empty: not is_empty

	set_start
			-- Define current position as the first.
		require
			not_empty: not is_empty
	
feature -- Removal

	remove
			-- Remove item at cursor position.
			-- Move cursor to right neighbor (cyclically).
			-- If removed item was at current starting position,
			-- move starting position to right neighbor.
	
invariant
	not_before_unless_empty: before implies is_empty
	not_after_unless_empty: after implies is_empty
	not_off_unless_empty: off implies is_empty

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

Generated by ISE EiffelStudio