public Trie < V > trimToSize ( ) { Queue < TrieNode < V >> queue = new LinkedList <> ( ) ; queue . add ( root ) ; while ( ! queue . isEmpty ( ) ) { TrieNode < V > node = queue . remove ( ) ; node . children . trimToSize ( ) ; queue . addAll ( node . children ) ; } return this ; }
Compresses the memory of the individual trie nodes .