Package banner.util

Class Trie<K,​V>

  • Type Parameters:
    K -
    V -

    public class Trie<K,​V>
    extends Object
    A Trie (also known as a prefix tree) essentially maps from a list of objects (keys) to a value. The interface is very similar, therefore, to the interface for Map, except that the key is a List of objects. This data structure allows searching in O(m) time, where m is the depth of the tree.
    Author:
    Bob
    • Constructor Detail

      • Trie

        public Trie()
      • Trie

        public Trie​(V value)
    • Method Detail

      • getValue

        public V getValue()
      • setValue

        public void setValue​(V value)
      • add

        public V add​(List<K> keys,
                     V value)
      • getChild

        public Trie<K,​V> getChild​(K key)
      • getValue

        public V getValue​(List<K> keys)
      • size

        public int size()
        Returns the number of mappings in this Trie
        Returns:
        The number of mappings in this Trie