Module id.xfunction

Class PrefixTrieSet

All Implemented Interfaces:
Iterable<String>, Collection<String>, Set<String>

public class PrefixTrieSet extends AbstractSet<String>
Set which keeps all elements in prefix trie data structure.

                *
              /   \
            h/    t\
            *       *
          e/        e\
          *           *
        l/            e\
        *               *
      l/ \            \0|
      /  p\             *
     *     *
   o/    \0|
   *       *
 \0|
   *
 

Items stored in sorted order.

It implements all methods of Set collection interface except remove.

Complexity is O(L) where L is length of the item.

Adding empty string is not allowed since empty string is a prefix of all possible strings. This would mean that Trie with empty string will match all strings and can cause a confusion.

This collection is not thread safe.