Click or drag to resize
TSTValue Class

The TST class represents an symbol table of key-value pairs, with string keys and generic values. It supports the usual Put, Get, Indexer, Contains, Delete, Count, and IsEmpty methods. It also provides character-based methods for finding the string in the symbol table that is the Longest prefix of a given prefix, finding all strings in the symbol table that Start with a given prefix, and finding all strings in the symbol table that Match a given pattern. A symbol table implements the Associative array abstraction: when associating a value with a key that is already in the symbol table, the convention is to replace the old value with the new value. Unlike DictionaryTKey, TValue, this class uses the convention that values cannot be null. Setting the value associated with a key to null is equivalent to deleting the key from the symbol table.

This implementation uses a ternary search trie.

Inheritance Hierarchy
SystemObject
  Algs4NetTSTValue

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class TST<Value>

Type Parameters

Value

The TSTValue type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCount
Returns the number of key-value pairs in this symbol table.
Public propertyItem
Indexer wrapping Get and Put for convenient syntax
Public propertyKeys
Returns all keys in the symbol table as an Iterable. To iterate over all of the keys in the symbol table named st, use the foreach notation: foreach (Key key in st.Keys).
Top
Methods
  NameDescription
Public methodContains
Does this symbol table contain the given key?
Public methodGet
Returns the value associated with the given key.
Public methodKeysThatMatch
Returns all of the keys in the symbol table 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 symbol table that is the longest prefix of query, or null, if no such string.
Public methodStatic memberMainTest
Demo test the TST data type.
Public methodPut
Inserts the key-value pair into the symbol table, overwriting the old value with the new value if the key is already in the symbol table. If the value is null, this effectively deletes the key from the symbol table.
Top
Remarks

For additional documentation, see Section 5.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class TST implementation by the respective authors.

See Also