AALanguage
The best language for those who have nothing to do
Loading...
Searching...
No Matches
TrieNode Class Reference

Trie-node class. More...

#include <Trie.h>

Public Member Functions

 TrieNode ()
 Default constructor.
 
 TrieNode (char c)
 Constructor specifying the symbol of the current node.
 
 ~TrieNode ()
 Destructor.
 
char get_char ()
 Gets the symbol of the current node.
 
std::map< char, TrieNode * > * get_next ()
 Gets transitions to child nodes.
 
int * get_ends ()
 Gets the number of strings ending in the given node.
 
int * get_count ()
 Gets the number of strings ending in subtrees.
 

Private Attributes

char _curr_char
 
std::map< char, TrieNode * > _next
 
int _ends
 
int _count
 

Detailed Description

Trie-node class.

The node stores within itself:

  • node symbol
  • map of transitions in children
  • number of words ending in this node
  • total number of words in subtrees

Definition at line 15 of file Trie.h.

Constructor & Destructor Documentation

◆ TrieNode() [1/2]

TrieNode::TrieNode ( )

Default constructor.

Definition at line 3 of file Trie.cpp.

References _count, _curr_char, and _ends.

◆ TrieNode() [2/2]

TrieNode::TrieNode ( char c)

Constructor specifying the symbol of the current node.

Parameters
cNode symbol

Definition at line 7 of file Trie.cpp.

References _count, _curr_char, and _ends.

◆ ~TrieNode()

TrieNode::~TrieNode ( )

Destructor.

Calls all child nodes destructors, causing all subtrie nodes to be removed.

Definition at line 11 of file Trie.cpp.

References _next.

Member Function Documentation

◆ get_char()

char TrieNode::get_char ( )

Gets the symbol of the current node.

Returns
The symbol of the current node.

Definition at line 17 of file Trie.cpp.

References _curr_char.

◆ get_count()

int * TrieNode::get_count ( )

Gets the number of strings ending in subtrees.

Returns
A pointer to the number of strings ending in subtrees.

Definition at line 26 of file Trie.cpp.

References _count.

Referenced by Trie::add(), and Trie::get_size().

◆ get_ends()

int * TrieNode::get_ends ( )

Gets the number of strings ending in the given node.

Returns
A pointer to the number of strings ending in the given node.

Definition at line 23 of file Trie.cpp.

References _ends.

Referenced by Trie::add(), and Trie::find().

◆ get_next()

std::map< char, TrieNode * > * TrieNode::get_next ( )

Gets transitions to child nodes.

Returns
A pointer to map<char, TrieNode*> - map of transitions in children by character.

Definition at line 20 of file Trie.cpp.

References _next.

Referenced by Trie::add(), and Trie::find().

Member Data Documentation

◆ _count

int TrieNode::_count
private

Definition at line 61 of file Trie.h.

Referenced by get_count(), TrieNode(), and TrieNode().

◆ _curr_char

char TrieNode::_curr_char
private

Definition at line 58 of file Trie.h.

Referenced by get_char(), TrieNode(), and TrieNode().

◆ _ends

int TrieNode::_ends
private

Definition at line 60 of file Trie.h.

Referenced by get_ends(), TrieNode(), and TrieNode().

◆ _next

std::map<char, TrieNode*> TrieNode::_next
private

Definition at line 59 of file Trie.h.

Referenced by get_next(), and ~TrieNode().


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