Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetTrieSET

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class TrieSET : IEnumerable<string>, 
	IEnumerable

The TrieSET type exposes the following members.

Constructors
  NameDescription
Public methodTrieSET
Initializes an empty set of strings.
Public methodTrieSET(Alphabet)
Initializes an empty string symbol table.
Top
Properties
  NameDescription
Public propertyCount
Returns the number of strings in the set.
Public propertyIsEmpty
Is the set empty?
Top
Methods
  NameDescription
Public methodAdd
Adds the key to the set if it is not already present.
Public methodContains
Does the set contain the given key?
Public methodDelete
Removes the key from the set if the key is present.
Public methodGetEnumerator
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).
Public methodKeysThatMatch
Returns all of the keys in the set that match pattern, where . symbol is treated as a wildcard character.
Public methodKeysWithPrefix
Returns all of the keys in the set that start with prefix.
Public methodLongestPrefixOf
Returns the string in the set that is the longest prefix of query, or null, if no such string.
Public methodStatic memberMainTest
Demo test the TrieSET data type.
Top
Fields
  NameDescription
Public fieldStatic memberExtendedASSCII
The default alphabet for the parameterless constructor
Top
Remarks

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.

See Also