INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Compact trees as active structures that may be traversed ", "using a cursor "
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: compact_cursor_tree, cursor_tree
cluster: eiffelbase
class COMPACT_CURSOR_TREE [G]
inherit

CURSOR_TREE [G]
rename
index as linear_index
redefine
extend,
has,
occurrences,
put_left
end
creation

make
feature -- Initialization

make (i: INTEGER)
-- Create an empty tree.
-- `i' is an estimate of the number of nodes.
ensure
is_above: above
is_empty: empty
feature -- Access

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

occurrences (v: G): INTEGER
-- Number of times `v' appears.
-- (Reference or object equality,
-- based on `object_comparison'.)

item: G
-- Current item

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

arity: INTEGER
-- Number of children

count: INTEGER
-- Number of items in subtree
feature -- Status report

after: BOOLEAN

before: BOOLEAN

above: BOOLEAN

isfirst: BOOLEAN
-- Is cursor on first sibling?

islast: BOOLEAN
-- Is cursor on last sibling?

is_root: BOOLEAN
-- Is cursor on root?

full: BOOLEAN

empty: BOOLEAN

prunable: BOOLEAN

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

back
-- Move cursor one position backward.

forth
-- Move cursor one position forward.

up
-- Move cursor one level upward, to parent
-- or `above' if `is_root' holds.

down (i: INTEGER)
-- Move cursor one level downward:
-- to `i'-th child if there is one,
-- or `after' if `i' = `arity' + 1,
-- or `before' if `i' = 0.
require
true

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

replace (v: G)
-- Replace current item by `v'
require
is_writable: writable

put_right (v: G)
-- Add a leaf `v' to the right of cursor position.

put_left (v: G)
-- Add `v' to the left of current position.
require
not_above: not above

put_front (v: G)
-- Add a leaf `v' as first child.
-- If `above' and `empty', make `v' the root value

put_parent (v: G)
-- insert a new node, with value v, as parent of
-- current node and
-- with the same position
--if above or on root, add a new root
require
not after
not before

extend (v: G)
feature -- Removal

remove
-- Remove node at cursor position
-- (and consequently the corresponding subtree).
-- Move cursor to next sibling, or `after' if none.
ensure
not_before: not before

remove_node
-- Remove node at cursor position; insert children into
-- parent's children at current position; move cursor up.
-- If node is root, it must not have more than one child.
require
not_off: not off
is_root implies arity <= 1

wipe_out
-- Remove all items.
ensure
cursor_above: above
end -- class COMPACT_CURSOR_TREE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES