Package components.binarytree
Interface BinaryTreeKernel<T>
- Type Parameters:
T- type ofBinaryTreeKernelnode 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 TypeMethodDescriptionvoidassemble(T root, BinaryTree<T> left, BinaryTree<T> right) Assembles inthisa tree with root labelrootand subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust be the same as the dynamic type ofthis.disassemble(BinaryTree<T> left, BinaryTree<T> right) Disassemblesthisinto its root label, which is returned as the value of the function, and subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust be the same as the dynamic type ofthis.intsize()Reports the size ofthis.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface components.standard.Standard
clear, newInstance, transferFrom
-
Method Details
-
assemble
Assembles inthisa tree with root labelrootand subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust 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
Disassemblesthisinto its root label, which is returned as the value of the function, and subtreesleftandright; the declaration notwithstanding, the dynamic type ofleftandrightmust 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|
-