C# Класс rmandvikar.Trie.Trie

Trie data structure.
Наследование: ITrie
Показать файл Открыть проект

Private Properties

Свойство Тип Описание
AddWord void
GetTrieNode TrieNode
GetWords void
Trie System.Collections.Generic

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

AddWord() публичный Метод

Add a word to the Trie.
public AddWord ( string word ) : void
word string
Результат void

GetWords() публичный Метод

Get all words in the Trie.
public GetWords ( ) : ICollection
Результат ICollection

GetWords() публичный Метод

Get words for given prefix.
public GetWords ( string prefix ) : ICollection
prefix string
Результат ICollection

HasWord() публичный Метод

Returns true or false if the word is present in the Trie.
public HasWord ( string word ) : bool
word string
Результат bool

WordCount() публичный Метод

Returns the count for the word in the Trie.
public WordCount ( string word ) : int
word string
Результат int