Interface BinaryTreeKernel<T>

Type Parameters:
T - type of BinaryTreeKernel node labels
All Superinterfaces:
Iterable<T>, Standard<BinaryTree<T>>
All Known Subinterfaces:
BinaryTree<T>
All Known Implementing Classes:
BinaryTree1, BinaryTreeSecondary

public interface BinaryTreeKernel<T> extends Standard<BinaryTree<T>>, Iterable<T>
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 Type
    Method
    Description
    void
    assemble(T root, BinaryTree<T> left, BinaryTree<T> right)
    Assembles in this a tree with root label root and subtrees left and right; the declaration notwithstanding, the dynamic type of left and right must be the same as the dynamic type of this.
    Disassembles this into its root label, which is returned as the value of the function, and subtrees left and right; the declaration notwithstanding, the dynamic type of left and right must be the same as the dynamic type of this .
    int
    Reports the size of this.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator

    Methods inherited from interface components.standard.Standard

    clear, newInstance, transferFrom
  • Method Details

    • assemble

      void assemble(T root, BinaryTree<T> left, BinaryTree<T> right)
      Assembles in this a tree with root label root and subtrees left and right; the declaration notwithstanding, the dynamic type of left and right must be the same as the dynamic type of this.
      Parameters:
      root - the root label
      left - the left subtree
      right - the right subtree
      Aliases:
      reference root
      Replaces:
      this
      Clears:
      left, right
      Ensures:
      this = compose(root, #left, #right)
    • disassemble

      T disassemble(BinaryTree<T> left, BinaryTree<T> right)
      Disassembles this into its root label, which is returned as the value of the function, and subtrees left and right; the declaration notwithstanding, the dynamic type of left and right must be the same as the dynamic type of this .
      Parameters:
      left - the left subtree
      right - 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 of this.
      Returns:
      the size
      Ensures:
      size = |this|