C# Class rmandvikar.Trie.Trie

Trie data structure.
Inheritance: ITrie
Mostra file Open project: vladislav-karamfilov/TelerikAcademy

Private Properties

Property Type Description
AddWord void
GetTrieNode TrieNode
GetWords void
Trie System.Collections.Generic

Public Methods

Method 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

Method 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 method

Add a word to the Trie.
public AddWord ( string word ) : void
word string
return void

GetWords() public method

Get all words in the Trie.
public GetWords ( ) : ICollection
return ICollection

GetWords() public method

Get words for given prefix.
public GetWords ( string prefix ) : ICollection
prefix string
return ICollection

HasWord() public method

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

WordCount() public method

Returns the count for the word in the Trie.
public WordCount ( string word ) : int
word string
return int