INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Circular chains, without commitment to a particular ", "representation "
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: circular, ring, sequence
cluster: eiffelbase
deferred class CIRCULAR [G]
inherit

CHAIN [G]
redefine
exhausted,
first,
go_i_th,
last,
move,
off,
remove,
valid_cursor_index
end
feature -- Access

first: like item
-- Item at position currently defined as first

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

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

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

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

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

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

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

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

back
-- Move cursor to previous item, cyclically.

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

go_i_th (i: INTEGER)
-- Move cursor to `i'-th position from current start, cyclically.
require
index_big_enough: i >= 1
not_empty: not empty

set_start
-- Define current position as the first.
require
not_empty: not 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 empty
not_after_unless_empty: after implies empty
not_off_unless_empty: off implies empty
end -- class CIRCULAR

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES