TrieSET Class |
The TrieSET class represents an ordered set of strings over the extended ASCII alphabet. It supports the usual Add, Contains, and Delete methods. It also provides character-based methods for finding the string in the set that is the Longest prefix of a given prefix, finding all strings in the set that Start with a given prefix, and finding all strings in the set that Match a given pattern.
This implementation uses a 256-way trie. The Add, Contains, Delete, and Longest prefix methods take time proportional to the length of the key (in the worst case). Construction takes constant time.
Namespace: Algs4Net
public class TrieSET : IEnumerable<string>, IEnumerable
The TrieSET type exposes the following members.
Name | Description | |
---|---|---|
![]() | TrieSET |
Initializes an empty set of strings. |
![]() | TrieSET(Alphabet) |
Initializes an empty string symbol table. |
Name | Description | |
---|---|---|
![]() | Add |
Adds the key to the set if it is not already present. |
![]() | Contains |
Does the set contain the given key? |
![]() | Delete |
Removes the key from the set if the key is present. |
![]() | GetEnumerator |
Returns all of the keys in the set, as an iterator.
To iterate over all of the keys in a set named set, use the
foreach notation: foreach (Key key in set). |
![]() | KeysThatMatch |
Returns all of the keys in the set that match pattern,
where . symbol is treated as a wildcard character. |
![]() | KeysWithPrefix |
Returns all of the keys in the set that start with prefix. |
![]() | LongestPrefixOf |
Returns the string in the set that is the longest prefix of query,
or null, if no such string. |
![]() ![]() | MainTest |
Demo test the TrieSET data type. |
Name | Description | |
---|---|---|
![]() ![]() | ExtendedASSCII |
The default alphabet for the parameterless constructor
|
For additional documentation, see Section 5.5 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class Huffman implementation by the respective authors.