fCraft  0.636
Custom Minecraft Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events
Classes | Public Member Functions | Properties | List of all members
fCraft.Trie< T > Class Template Reference

Specialized data structure for partial-matching of large sparse sets of words. Used as a searchable index of players for PlayerDB. More...

Inheritance diagram for fCraft.Trie< T >:
Inheritance graph
[legend]
Collaboration diagram for fCraft.Trie< T >:
Collaboration graph
[legend]

Classes

class  TrieKeyCollection
 
class  TrieSubset
 A subset of trie's key/value pairs that start with a certain prefix. More...
 
class  TrieValueCollection
 

Public Member Functions

 Trie ()
 Creates a new empty trie.
 
 Trie ([NotNull] IEnumerable< KeyValuePair< string, T >> dictionary)
 Creates a new trie from an existing dictionary. Values are shallowly copied.
 
bool ContainsValue ([NotNull] T value)
 Checks whether the trie contains a given value. This method uses the value enumerator and runs in O(n).
 
bool GetOneMatch ([NotNull] string keyPart, out T payload)
 Searches for payloads with keys that start with keyPart, returning just one or none of the matches.
 
List< T > GetList ([NotNull] string keyPart, int limit)
 Finds a list of payloads with keys that start with keyPart, up to a specified limit. Autocompletes.
 
bool Add ([NotNull] string key,[NotNull] T payload, bool overwriteOnDuplicate)
 Adds a new object by key.
 
Get ([NotNull] string key)
 Get payload for an exact key (no autocompletion).
 
IEnumerable< T > ValuesStartingWith (string prefix)
 Finds a subset of values whose keys start with a given prefix.
 
IEnumerable< string > KeysStartingWith (string prefix)
 Finds a subset of keys that start with a given prefix.
 
IEnumerable< KeyValuePair
< string, T > > 
StartingWith (string prefix)
 Finds a subset of key/value pairs that start with a given prefix.
 
void Add (string key, T payload)
 Adds a new object by key. If an entry for this key already exists, it is NOT overwritten.
 
bool TryGetValue (string key, out T result)
 Tries to get a value by full key.
 
bool ContainsKey (string key)
 Checks whether the trie contains a given full key.
 
bool Remove (string key)
 Removes an entry by key.
 
void Clear ()
 Removes all keys/values from the trie, making it empty.
 
IEnumerator< KeyValuePair
< string, T > > 
GetEnumerator ()
 
void Add (KeyValuePair< string, T > pair)
 
bool Contains (KeyValuePair< string, T > pair)
 
bool Remove (KeyValuePair< string, T > pair)
 
void CopyTo (KeyValuePair< string, T >[] pairArray, int index)
 
void CopyTo (Array pairArray, int index)
 
object Clone ()
 

Properties

ICollection< string > Keys [get]
 
ICollection< T > Values [get]
 
this[string key] [get, set]
 
bool IsFixedSize [get]
 
int Count [get, set]
 
bool IsReadOnly [get]
 
bool IsSynchronized [get]
 
object SyncRoot [get]
 

Detailed Description

Specialized data structure for partial-matching of large sparse sets of words. Used as a searchable index of players for PlayerDB.

Template Parameters
TPayload type (reference types only).
Type Constraints
T :class 

Constructor & Destructor Documentation

fCraft.Trie< T >.Trie ( )

Creates a new empty trie.

fCraft.Trie< T >.Trie ( [NotNull] IEnumerable< KeyValuePair< string, T >>  dictionary)

Creates a new trie from an existing dictionary. Values are shallowly copied.

Parameters
dictionarySource dictionary to copy from.

Member Function Documentation

bool fCraft.Trie< T >.Add ( [NotNull] string  key,
[NotNull] T  payload,
bool  overwriteOnDuplicate 
)

Adds a new object by key.

Parameters
keyFull key.
payloadObject associated with the key.
overwriteOnDuplicateWhether to overwrite the value in case this key already exists.
Returns
True if object was added, false if an entry for this key already exists.
void fCraft.Trie< T >.Add ( string  key,
payload 
)

Adds a new object by key. If an entry for this key already exists, it is NOT overwritten.

Parameters
keyFull key.
payloadObject associated with the key.
Returns
True if object was added, false if an entry for this key already exists.
void fCraft.Trie< T >.Add ( KeyValuePair< string, T >  pair)
void fCraft.Trie< T >.Clear ( )

Removes all keys/values from the trie, making it empty.

object fCraft.Trie< T >.Clone ( )
bool fCraft.Trie< T >.Contains ( KeyValuePair< string, T >  pair)
bool fCraft.Trie< T >.ContainsKey ( string  key)

Checks whether the trie contains a given full key.

Parameters
keyFull key to search for.
Returns
True if the trie contains a given key.
bool fCraft.Trie< T >.ContainsValue ( [NotNull] T  value)

Checks whether the trie contains a given value. This method uses the value enumerator and runs in O(n).

Parameters
valueValue to search for.
Returns
True if the trie contains at least one copy of the value.
void fCraft.Trie< T >.CopyTo ( KeyValuePair< string, T >[]  pairArray,
int  index 
)
void fCraft.Trie< T >.CopyTo ( Array  pairArray,
int  index 
)
T fCraft.Trie< T >.Get ( [NotNull] string  key)

Get payload for an exact key (no autocompletion).

Parameters
keyFull key.
Returns
Payload object, if found. Null if not found.
IEnumerator<KeyValuePair<string, T> > fCraft.Trie< T >.GetEnumerator ( )
List<T> fCraft.Trie< T >.GetList ( [NotNull] string  keyPart,
int  limit 
)

Finds a list of payloads with keys that start with keyPart, up to a specified limit. Autocompletes.

Parameters
keyPartPartial or full key.
limitLimit on the number of payloads to find/return.
Returns
List of matches (if there are no matches, length is zero).
bool fCraft.Trie< T >.GetOneMatch ( [NotNull] string  keyPart,
out T  payload 
)

Searches for payloads with keys that start with keyPart, returning just one or none of the matches.

Parameters
keyPartPartial or full key.
payloadPayload object to output (will be set to null if no single match was found).
Returns
If no matches were found, returns true and sets payload to null. If one match was found, returns true and sets payload to the value. If more than one match was found, returns false and sets payload to null.
IEnumerable<string> fCraft.Trie< T >.KeysStartingWith ( string  prefix)

Finds a subset of keys that start with a given prefix.

Parameters
prefixKey prefix.
Returns
Enumeration of keys.
bool fCraft.Trie< T >.Remove ( string  key)

Removes an entry by key.

Parameters
keyKey for the entry to remove.
Returns
True if the entry was removed, false if no entry was found for this key.
bool fCraft.Trie< T >.Remove ( KeyValuePair< string, T >  pair)
IEnumerable<KeyValuePair<string, T> > fCraft.Trie< T >.StartingWith ( string  prefix)

Finds a subset of key/value pairs that start with a given prefix.

Parameters
prefixKey prefix.
Returns
Enumeration of key/value pairs.
bool fCraft.Trie< T >.TryGetValue ( string  key,
out T  result 
)

Tries to get a value by full key.

Parameters
keyFull key to search for.
resultResult.
Returns
True of a value was found for this key.
IEnumerable<T> fCraft.Trie< T >.ValuesStartingWith ( string  prefix)

Finds a subset of values whose keys start with a given prefix.

Parameters
prefixKey prefix.
Returns
Enumeration of values.

Property Documentation

int fCraft.Trie< T >.Count
getset
bool fCraft.Trie< T >.IsFixedSize
get
bool fCraft.Trie< T >.IsReadOnly
get
bool fCraft.Trie< T >.IsSynchronized
get
ICollection<string> fCraft.Trie< T >.Keys
get
object fCraft.Trie< T >.SyncRoot
get
T fCraft.Trie< T >.this[string key]
getset
ICollection<T> fCraft.Trie< T >.Values
get

The documentation for this class was generated from the following file: