INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Sequential, one-way linked lists"
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: linked_list, sequence
cluster: eiffelbase
class LINKED_LIST [G]
inherit

DYNAMIC_LIST [G]
redefine
after,
before,
finish,
first,
go_i_th,
isfirst,
islast,
last,
merge_left,
merge_right,
move,
off,
put_left,
readable,
start,
wipe_out
end
creation

make
feature -- Initialization

make
-- Create an empty list.
ensure
is_before: before
feature -- Access

item: G
-- Current item

first: like item
-- Item at first position

last: like item
-- Item at last position

index: INTEGER
-- Index of current position

cursor: CURSOR
-- Current cursor position
feature -- Measurement

count: INTEGER
feature -- Status report

readable: BOOLEAN
-- Is there a current item that may be read?

after: BOOLEAN

before: BOOLEAN

off: BOOLEAN
-- Is there no current item?

isfirst: BOOLEAN
-- Is cursor at first position?

islast: BOOLEAN
-- Is cursor at last position?

valid_cursor (p: CURSOR): BOOLEAN
-- Can the cursor be moved to position `p'?

full: BOOLEAN
feature -- Cursor movement

start
-- Move cursor to first position.
ensure
empty_convention: empty implies after

finish
-- Move cursor to last position.
-- (Go before if empty)
ensure
empty_convention: empty implies before

forth
-- Move cursor to next position.

back
-- Move to previous item.

move (i: INTEGER)
-- Move cursor `i' positions. The cursor
-- may end up `off' if the offset is too big.
ensure
moved_if_inbounds: (( index + i) >= 0 and ( index + i) <= (count + 1)) implies index = ( index + i)
before_set: ( index + i) <= 0 implies before
after_set: ( index + i) >= (count + 1) implies after

go_i_th (i: INTEGER)
-- Move cursor to `i'-th position.

go_to (p: CURSOR)
-- Move cursor to position `p'.
feature -- Element change

put_front (v: G)
-- Add `v' to beginning.
-- Do not move cursor.

extend (v: G)
-- Add `v' to end.
-- Do not move cursor.

put_left (v: G)
-- Add `v' to the left of cursor position.
-- Do not move cursor.
ensure
previous_exists: previous /= void
item_inserted: previous.item = v

put_right (v: G)
-- Add `v' to the right of cursor position.
-- Do not move cursor.
ensure
next_exists: next /= void
item_inserted: not before implies next.item = v
item_inserted_before: before implies active.item = v

replace (v: G)
-- Replace current item by `v'.

merge_left (other: like Current)
-- Merge `other' into current structure before cursor
-- position. Do not move cursor. Empty `other'.

merge_right (other: like Current)
-- Merge `other' into current structure after cursor
-- position. Do not move cursor. Empty `other'.
feature -- Removal

remove
-- Remove current item.
-- Move cursor to right neighbor
-- (or `after' if no right neighbor).

remove_left
-- Remove item to the left of cursor position.
-- Do not move cursor.

remove_right
-- Remove item to the right of cursor position.
-- Do not move cursor.

wipe_out
-- Remove all items.
invariant

prunable: prunable
empty_constraint: empty implies ((first_element = void) and (active = void))
not_void_unless_empty: (active = void) implies empty
before_constraint: before implies (active = first_element)
after_constraint: after implies (active = last_element)
end -- class LINKED_LIST

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES