inLimbo
TUI Music Player that keeps you in Limbo.
 
Loading...
Searching...
No Matches
Trie Class Reference

Implements the Trie (Prefix Tree) data structure. More...

#include <trie.hpp>

Public Member Functions

 Trie ()
 
void insert (const std::string &word, int index)
 Inserts a word into the Trie.
 
auto search (const std::string &prefix) -> std::vector< int >
 Searches for words starting with a given prefix.
 
void deleteWord (const std::string &word, int index)
 Deletes a word from the Trie.
 
void clear ()
 Clears all nodes in the Trie.
 
auto is_empty () const -> bool
 Checks if the Trie is empty.
 

Detailed Description

Implements the Trie (Prefix Tree) data structure.

This class provides methods to insert artist names into the Trie and search for all names that start with a given prefix. It stores a list of indices for each node, making it efficient to retrieve all matching names for a prefix.

Constructor & Destructor Documentation

◆ Trie()

Trie::Trie ( )
inline

Member Function Documentation

◆ clear()

void Trie::clear ( )
inline

Clears all nodes in the Trie.

◆ deleteWord()

void Trie::deleteWord ( const std::string & word,
int index )
inline

Deletes a word from the Trie.

Parameters
wordThe word to delete.
indexThe index associated with the word.

◆ insert()

void Trie::insert ( const std::string & word,
int index )
inline

Inserts a word into the Trie.

Parameters
wordThe word to insert.
indexThe index associated with the word.

◆ is_empty()

auto Trie::is_empty ( ) const -> bool
inlinenodiscard

Checks if the Trie is empty.

Returns
True if the Trie is empty, false otherwise.

◆ search()

auto Trie::search ( const std::string & prefix) -> std::vector<int>
inline

Searches for words starting with a given prefix.

Parameters
prefixThe search prefix.
Returns
A vector of indices of matching words.

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