INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "Binary search trees; left child item is less than current ", "item, right child item is greater "
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: binary_search_tree, tree
cluster: eiffelbase
class BINARY_SEARCH_TREE [G -> COMPARABLE]
inherit

BINARY_TREE [G]
rename
make as bt_make,
put as bt_put
export
{BINARY_SEARCH_TREE}
put_left_child,
put_right_child,
remove_left_child,
remove_right_child
redefine
has,
parent
end
creation

make
feature -- Initialization

make (v: G)
-- Create single node with item `v'.
ensure
node_item: item = v
no_child: (left_child = void) and (right_child = void)
feature -- Access

parent: like Current

has (v: G): BOOLEAN
-- Does tree contain a node whose item
-- is equal to `v' (object comparison)?
require
argument_not_void: v /= void
feature -- Measurement

min: G
-- Minimum item in tree
ensure
minimum_present: has (Result)

max: G
-- Maximum item in tree
ensure
maximum_present: has (Result)
feature -- Status report

sorted: BOOLEAN
-- Is tree sorted?
feature -- Cursor movement

node_action (v: G)
-- Operation on node item,
-- to be defined by descendant classes.
-- Here it is defined as an empty operation.
-- Redefine this procedure in descendant classes if useful
-- operations are to be performed during traversals.

preorder
-- Apply `node_action' to every node's item
-- in tree, using pre-order.

i_infix
-- Apply node_action to every node's item
-- in tree, using infix order.

postorder
-- Apply node_action to every node's item
-- in tree, using post-order.
feature -- Element change

put, extend (v: G)
-- Put `v' at proper position in tree
-- (unless `v' exists already).
-- (Reference or object equality,
-- based on `object_comparison'.)
require
new_item_exists: v /= void
ensure
item_inserted: has (v)
feature -- Transformation

sort
-- Sort tree.
--| Uses heapsort.
--| The reason for the `external sort' is that
--| the insertion order in the tree will ensure
--| it is balanced
ensure
is_sorted: sorted
end -- class BINARY_SEARCH_TREE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES