private int setWordsHelper(List<L> words, int wordNum) { if (isLeaf()) { label = words.get(wordNum); return wordNum + 1; } else { for (Tree<L> child : getChildren()) wordNum = child.setWordsHelper(words, wordNum); return wordNum; } }
/* Set the words at the leaves of a tree to the words from the * list */ public void setWords(List<L> words) { setWordsHelper(words, 0); }