C# Class rmandvikar.Trie.Trie

Trie data structure.
Inheritance: ITrie
Afficher le fichier Open project: vladislav-karamfilov/TelerikAcademy

Private Properties

Свойство Type Description
AddWord void
GetTrieNode TrieNode
GetWords void
Trie System.Collections.Generic

Méthodes publiques

Méthode Description
AddWord ( string word ) : void

Add a word to the Trie.

GetWords ( ) : ICollection

Get all words in the Trie.

GetWords ( string prefix ) : ICollection

Get words for given prefix.

HasWord ( string word ) : bool

Returns true or false if the word is present in the Trie.

WordCount ( string word ) : int

Returns the count for the word in the Trie.

Private Methods

Méthode Description
AddWord ( TrieNode trieNode, char word ) : void

Recursive method to add word. Gets the first char of the word, creates the child TrieNode if null, and recurses with the first char removed from the word. If the word length is 0, return.

GetTrieNode ( string prefix ) : TrieNode

Get the equivalent TrieNode in the Trie for given prefix. If prefix not present, then return null.

GetWords ( TrieNode trieNode, ICollection words, StringBuilder buffer ) : void

Recursive method to get all the words starting from given TrieNode.

Trie ( TrieNode rootTrieNode ) : System.Collections.Generic

Create a new Trie instance.

Method Details

AddWord() public méthode

Add a word to the Trie.
public AddWord ( string word ) : void
word string
Résultat void

GetWords() public méthode

Get all words in the Trie.
public GetWords ( ) : ICollection
Résultat ICollection

GetWords() public méthode

Get words for given prefix.
public GetWords ( string prefix ) : ICollection
prefix string
Résultat ICollection

HasWord() public méthode

Returns true or false if the word is present in the Trie.
public HasWord ( string word ) : bool
word string
Résultat bool

WordCount() public méthode

Returns the count for the word in the Trie.
public WordCount ( string word ) : int
word string
Résultat int