Beispiel #1
0
 public void preOrderTraversal(LambdaOne<IntBinaryTree> function) {
   // Visit this node.
   function.call(this);
   // Pre-order traversal of each child.
   if (leftChild != null) {
     leftChild.preOrderTraversal(function);
   }
   if (rightChild != null) {
     rightChild.preOrderTraversal(function);
   }
 }
Beispiel #2
0
 public void resetAlphabets(
     final Alphabet<String> lexAlphabet, final Alphabet<String> ntAlphabet) {
   preOrderTraversal(
       new LambdaOne<IntBinaryTree>() {
         public void call(IntBinaryTree node) {
           String label = node.getSymbolLabel();
           node.alphabet = node.isLexical ? lexAlphabet : ntAlphabet;
           node.setSymbolLabel(label);
         }
       });
 }