Workspace 6.21.5
Public Types | Public Member Functions | List of all members
Trie Class Reference

Super basic trie class for validating strings. Speeds up the code needed for some autocomplete / validation used in QLineEdits. More...

#include <DataAnalysis/DataStructures/trie.h>

Public Types

enum  State { Invalid = QValidator::Invalid , Intermediate = QValidator::Intermediate , Accepted = QValidator::Acceptable }
 

Public Member Functions

 Trie ()
 
 Trie (const QStringList &strings)
 
 ~Trie ()
 
void addString (const QString &string)
 
void addStrings (const QStringList &strings)
 
int charCount (bool includeNullChars=false) const
 
void clear ()
 
bool empty () const
 
State validate (const QString &string) const
 

Detailed Description

To use it, add as many strings as you like to the trie, then validate input strings using the validate function.

Member Enumeration Documentation

◆ State

enum State
Enumerator
Invalid 
Intermediate 
Accepted 

Constructor & Destructor Documentation

◆ Trie() [1/2]

Trie ( )

◆ Trie() [2/2]

Trie ( const QStringList strings)
Parameters
stringsList of strings to initialise the trie with.

◆ ~Trie()

~Trie ( )

Member Function Documentation

◆ addString()

void addString ( const QString &  str)
Parameters
strThe string to be inserted into the trie.

Adds a string to the trie so that it's available for validation.

◆ addStrings()

void addStrings ( const QStringList strings)
Parameters
stringsThe strings to add to the trie.

◆ charCount()

int charCount ( bool  includeNullChars = false) const
Parameters
includeNullCharsIf enabled, this will include the null terminator characters in the count.
Returns
the total number of chars stored in the trie.

◆ clear()

void clear ( )

Clears the trie, ensuring it has no values.

◆ empty()

bool empty ( ) const

◆ validate()

Trie::State validate ( const QString &  string) const
Parameters
stringThe string to validate.
Returns
Invalid if the string is not contained within the Trie, Intermediate if the string matches internal nodes of the Trie, and Accepted if the string is a complete match for one of the elements in the trie.