Package components.binarytree
Interface BinaryTreeKernel<T>
- Type Parameters:
T
- type ofBinaryTreeKernel
node labels
- All Superinterfaces:
Iterable<T>
,Standard<BinaryTree<T>>
- All Known Subinterfaces:
BinaryTree<T>
- All Known Implementing Classes:
BinaryTree1
,BinaryTreeSecondary
Binary tree kernel component with primary methods. (Note: by package-wide
convention, all references are non-null.)
- Mathematical Definitions:
IN_ORDER( tree: binary tree of T ): string of T satisfies if tree = empty_tree then IN_ORDER(tree) = <> else there exists root: T, left, right: binary tree of T (tree = compose(root, left, right) and IN_ORDER(tree) = IN_ORDER(left) * <root> * IN_ORDER(right))
- Mathematical Model (abstract value and abstract invariant of this):
type BinaryTreeKernel is modeled by binary tree of T
- Constructor(s) (initial abstract value(s) of this):
(): ensures this = empty_tree
- Iterator String (abstract value of ~this):
~this.seen * ~this.unseen = IN_ORDER(this)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assemble
(T root, BinaryTree<T> left, BinaryTree<T> right) Assembles inthis
a tree with root labelroot
and subtreesleft
andright
; the declaration notwithstanding, the dynamic type ofleft
andright
must be the same as the dynamic type ofthis
.disassemble
(BinaryTree<T> left, BinaryTree<T> right) Disassemblesthis
into its root label, which is returned as the value of the function, and subtreesleft
andright
; the declaration notwithstanding, the dynamic type ofleft
andright
must be the same as the dynamic type ofthis
.int
size()
Reports the size ofthis
.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
assemble
Assembles inthis
a tree with root labelroot
and subtreesleft
andright
; the declaration notwithstanding, the dynamic type ofleft
andright
must be the same as the dynamic type ofthis
.- Parameters:
root
- the root labelleft
- the left subtreeright
- the right subtree- Aliases:
- reference
root
- Replaces:
this
- Clears:
left, right
- Ensures:
this = compose(root, #left, #right)
-
disassemble
Disassemblesthis
into its root label, which is returned as the value of the function, and subtreesleft
andright
; the declaration notwithstanding, the dynamic type ofleft
andright
must be the same as the dynamic type ofthis
.- Parameters:
left
- the left subtreeright
- the right subtree- Returns:
- the root label
- Replaces:
left, right
- Clears:
this
- Requires:
this /= empty_tree
- Ensures:
#this = compose(disassemble, left, right)
-
size
int size()Reports the size ofthis
.- Returns:
- the size
- Ensures:
size = |this|
-