Class SuffixTrie<V>


  • public class SuffixTrie<V>
    extends Object
    • Constructor Detail

      • SuffixTrie

        public SuffixTrie()
    • Method Detail

      • put

        public V put​(String suffix,
                     V value)
        Insert a string and an associated value into the trie. If the string is already present in the trie, the existing value is replaced by the new value.
        Parameters:
        suffix - suffix string inserted into trie
        value - value associated with string
        Returns:
        previous value associated with string or null if there was no previous value
      • get

        public V get​(String suffix)
        Get value associated with suffix string in trie.
        Parameters:
        suffix - suffix string searched in trie
        Returns:
        value if suffix is found in trie, null otherwise
      • contains

        public boolean contains​(String suffix)
        Checks whether trie contains a suffix string.
        Parameters:
        suffix - suffix string searched in trie
        Returns:
        true if suffix is found in trie
      • getLongestSuffix

        protected SuffixTrie.LookupResult<V> getLongestSuffix​(String string)
        Match the longest suffix of a string contained in trie.
        Parameters:
        string - to be checked for a contained (longest) suffix
        Returns:
        lookup result or null if no suffix is found
      • getSuffixes

        protected List<SuffixTrie.LookupResult<V>> getSuffixes​(String string)
        Match all suffixes of a string contained in trie.
        Parameters:
        string - string to be checked for suffixes contained in trie
        Returns:
        list of suffix lookup results, from shortest to longest