INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Dynamically modifiable chains"
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: dynamic_chain, sequence
cluster: eiffelbase
deferred class DYNAMIC_CHAIN [G]
inherit

CHAIN [G]
export
{ANY}
prune,
prune_all,
remove
undefine
prune,
prune_all,
remove
end

UNBOUNDED [G]
end
feature -- Status report

extendible: BOOLEAN

prunable: BOOLEAN
-- May items be removed? (Answer: yes.)
feature -- Element change

put_front (v: G)
-- Add `v' at beginning.
-- Do not move cursor.
ensure
new_count: count = count + 1
item_inserted: first = v

put_left (v: G)
-- Add `v' to the left of cursor position.
-- Do not move cursor.
require
extendible: extendible
not_before: not before
ensure
new_count: count = count + 1
new_index: index = index + 1

put_right (v: G)
-- Add `v' to the right of cursor position.
-- Do not move cursor.
require
extendible: extendible
not_after: not after
ensure
new_count: count = count + 1
same_index: index = index

merge_left (other: like Current)
-- Merge `other' into current structure before cursor
-- position. Do not move cursor. Empty `other'.
require
extendible: extendible
not_off: not before
other_exists: other /= void
ensure
new_count: count = count + other.count
new_index: index = index + other.count
other_is_empty: other.empty

merge_right (other: like Current)
-- Merge `other' into current structure after cursor
-- position. Do not move cursor. Empty `other'.
require
extendible: extendible
not_off: not after
other_exists: other /= void
ensure
new_count: count = count + other.count
same_index: index = index
other_is_empty: other.empty
feature -- Removal

prune (v: G)
-- Remove first occurrence of `v', if any,
-- after cursor position.
-- If found, move cursor to right neighbor;
-- if not, make structure `exhausted'.

remove_left
-- Remove item to the left of cursor position.
-- Do not move cursor.
require
left_exists: index > 1
ensure
new_count: count = count - 1
new_index: index = index - 1

remove_right
-- Remove item to the right of cursor position.
-- Do not move cursor.
require
right_exists: index < count
ensure
new_count: count = count - 1
same_index: index = index

prune_all (v: G)
-- Remove all occurrences of `v'.
-- (Reference or object equality,
-- based on `object_comparison'.)
-- Leave structure `exhausted'.
ensure
is_exhausted: exhausted

wipe_out
-- Remove all items.
feature -- Duplication

duplicate (n: INTEGER): like Current
-- Copy of sub-chain beginning at current position
-- and having min (`n', `from_here') items,
-- where `from_here' is the number of items
-- at or to the right of current position.
invariant

extendible: extendible
end -- class DYNAMIC_CHAIN

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES