My Project
Public Member Functions | Public Attributes | List of all members
Trie Class Reference

Trie class. Available member functions include default constructor, find, insert, checkPrefix and countPrefix. More...

#include <DSA.h>

Public Member Functions

 Trie ()
 Construct a new Trie object.
 
bool find (Trie *T, char c)
 Find a char in a trie. More...
 
void insert (string s)
 Insert string into a trie. More...
 
bool checkPrefix (string s)
 Check if a string is a prefix. More...
 
ll countPrefix (string s)
 Count how many strings have the given prefix. More...
 

Public Attributes

ll count
 count of the string from root to leaf
 
map< char, Trie * > nodes
 map/dictionary of nodes
 

Detailed Description

Trie class. Available member functions include default constructor, find, insert, checkPrefix and countPrefix.

Member Function Documentation

◆ checkPrefix()

bool Trie::checkPrefix ( string  s)

Check if a string is a prefix.

Parameters
[in]sstring to check
Returns
true/false

◆ countPrefix()

ll Trie::countPrefix ( string  s)

Count how many strings have the given prefix.

Parameters
[in]sprefix to check
Returns
ll

◆ find()

bool Trie::find ( Trie T,
char  c 
)

Find a char in a trie.

Parameters
[in]Ttrie root pointer
[in]cchar to find
Returns
true/false

◆ insert()

void Trie::insert ( string  s)

Insert string into a trie.

Parameters
[in]sstring to insert

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