# SuffixTrie (Crawler-commons 1.1 API)
Date: 2020-06-25

crawlercommons.domains

## Class SuffixTrie<V>

- java.lang.Object
- - crawlercommons.domains.SuffixTrie<V>

    public class SuffixTrie<V>
    extends Object

### Nested Class Summary

Nested Classes
`static class` `SuffixTrie.LookupResult<V>` Wrapper for results when a string is checked for suffixes contained in the suffix trie.
`protected static class` `SuffixTrie.Node<V>`

### Field Summary

Fields
`protected SuffixTrie.Node<V>` `root`

### Constructor Summary

Constructors
Constructor and Description
`SuffixTrie()`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `contains(String suffix)` Checks whether trie contains a suffix string.
`V` `get(String suffix)` Get value associated with suffix string in trie.
`protected SuffixTrie.LookupResult<V>` `getLongestSuffix(String string)` Match the longest suffix of a string contained in trie.
`protected List<SuffixTrie.LookupResult<V>>` `getSuffixes(String string)` Match all suffixes of a string contained in trie.
`V` `put(String suffix, V value)` Insert a string and an associated value into the trie.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### root

    protected SuffixTrie.Node<V> root

### 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