private void calcNumWords() {
        if (numWordsCalculated) {
            return;
        }

        int words = 0;

        // The number of words reachable from this node is considered to be the number of words
        // reachable from it's children, and +1 if the node itself is a word.
        if (value.isPresent()) {
            words++;
        }

        for (TrieNode<T> child : children.values()) {
            child.calcNumWords();
            words += child.numWords;
        }

        numWords = words;
        numWordsCalculated = true;
    }
private void calcNumWords ( ) { if ( numWordsCalculated ) { return ; } int words = 0 ; if ( value . isPresent ( ) ) { words ++ ; } for ( TrieNode < T > child : children . values ( ) ) { child . calcNumWords ( ) ; words += child . numWords ; } numWords = words ; numWordsCalculated = true ; }
The amount of words reachable from this node is cached.<br>
This should be called after an outside changed had occurred and the amount was possibly changed.