FLImaging 6.7.1.3
FLImaging::Foundation::CTrie Class Reference

Implements a Trie structure for efficient string searching. More...

#include <Trie.h>

Public Member Functions

 CTrie ()
 Default constructor.
 CTrie (const CTrie &rhs)
 Copy constructor for the CTrie class.
 CTrie (const CTrie *pRhs)
 Pointer-based copy constructor for the CTrie class.
virtual ~CTrie ()
 Destructor.
virtual const CResult Assign (const CTrie &rhs)
 Assigns properties from another CTrie object using a reference.
virtual const CResult Assign (const CTrie *pRhs)
 Assigns properties from another CTrie object using a pointer.
virtual const CResult SetNodeTemplate (const CTrieNode *pTrieNodeTemplate)
 Sets the node template used for creating new nodes.
virtual const CTrieNodeGetNodeTemplate () const
 Gets the current node template.
virtual CTrieNodeInsert (const std::wstring &wstrWord)
 Inserts a word into the CTrie.
virtual const CResult Remove (const std::wstring &wstrWord)
 Removes a word from the Trie.
virtual CTrieNodeRename (const std::wstring &wstrOldWord, const std::wstring &wstrNewWord)
 Edits an existing word in the Trie.
virtual bool FindExact (const std::wstring &wstrWord) const
 Searches for an exact word.
virtual bool FindSubstring (const std::wstring &wstrSubstring, std::vector< std::wstring > &vctResults) const
 Searches for words containing a given substring.
virtual const CResult Clear ()
 Clears all data in the Trie.
virtual const CTrieNodeFindExactNode (const std::wstring &wstrWord) const
 Returns the node where the given word exactly matches.

Protected Member Functions

virtual const CTrieNodeFindNode (const std::wstring &wstrKey) const
 Finds a specific key in the Trie.
virtual bool RemoveHelper (CTrieNode *pNode, const std::wstring &wstrWord, int32_t i32Depth)
 Recursively removes a word from the Trie.
virtual void CollectWords (const CTrieNode *pNode, std::vector< std::wstring > &vctResults) const
 Collects all words ending at a given node.
virtual wchar_t NormalizeChar (wchar_t ch) const
 Normalizes a character to handle case-insensitive search.

Protected Attributes

CTrieNodem_pRoot
CTrieNodem_pNodeTemplate

Detailed Description

Implements a Trie structure for efficient string searching.

A class that implements a Trie structure for efficient string searching.

Constructor & Destructor Documentation

◆ CTrie() [1/2]

FLImaging::Foundation::CTrie::CTrie ( const CTrie & rhs)

Copy constructor for the CTrie class.

Parameters
[in]rhsReference to the object to copy.

◆ CTrie() [2/2]

FLImaging::Foundation::CTrie::CTrie ( const CTrie * pRhs)

Pointer-based copy constructor for the CTrie class.

Parameters
[in]pRhsPointer to the object to copy.

Member Function Documentation

◆ Assign() [1/2]

virtual const CResult FLImaging::Foundation::CTrie::Assign ( const CTrie & rhs)
virtual

Assigns properties from another CTrie object using a reference.

Parameters
[in]rhsReference to the object to copy properties from.
Return values
constFLImaging::CResult Result of the assignment operation.
See also
FLImaging::CResult

◆ Assign() [2/2]

virtual const CResult FLImaging::Foundation::CTrie::Assign ( const CTrie * pRhs)
virtual

Assigns properties from another CTrie object using a pointer.

Parameters
[in]pRhsPointer to the object to copy properties from.
Return values
constFLImaging::CResult Result of the assignment operation.
See also
FLImaging::CResult

◆ Clear()

virtual const CResult FLImaging::Foundation::CTrie::Clear ( )
virtual

Clears all data in the Trie.

Return values
FLImaging::CResultThe result of the clearing operation.

◆ CollectWords()

virtual void FLImaging::Foundation::CTrie::CollectWords ( const CTrieNode * pNode,
std::vector< std::wstring > & vctResults ) const
protectedvirtual

Collects all words ending at a given node.

Parameters
[in]pNodeThe starting node.
[out]vctResultsA vector containing found words.

◆ FindExact()

virtual bool FLImaging::Foundation::CTrie::FindExact ( const std::wstring & wstrWord) const
virtual

Searches for an exact word.

Parameters
[in]wstrWordThe word to search.
Return values
booltrue If the word exists. false If the word does not exist.

◆ FindExactNode()

virtual const CTrieNode * FLImaging::Foundation::CTrie::FindExactNode ( const std::wstring & wstrWord) const
virtual

Returns the node where the given word exactly matches.

Parameters
[in]wstrWordThe word to search.
Return values
constCTrieNode* The node that exactly matches the given word.

◆ FindNode()

virtual const CTrieNode * FLImaging::Foundation::CTrie::FindNode ( const std::wstring & wstrKey) const
protectedvirtual

Finds a specific key in the Trie.

Parameters
[in]wstrKeyThe key to search.
Return values
FLImaging::Foundation::CTrieNode*Pointer to the corresponding node (nullptr if not found).

◆ FindSubstring()

virtual bool FLImaging::Foundation::CTrie::FindSubstring ( const std::wstring & wstrSubstring,
std::vector< std::wstring > & vctResults ) const
virtual

Searches for words containing a given substring.

Parameters
[in]wstrSubstringThe substring to search for.
[out]vctResultsA vector containing found words.
Return values
booltrue If matching words are found. false If no matches are found.

◆ GetNodeTemplate()

virtual const CTrieNode * FLImaging::Foundation::CTrie::GetNodeTemplate ( ) const
virtual

Gets the current node template.

Return values
constCTrieNode* Pointer to the current node template.

◆ Insert()

virtual CTrieNode * FLImaging::Foundation::CTrie::Insert ( const std::wstring & wstrWord)
virtual

Inserts a word into the CTrie.

Parameters
[in]wstrWordThe word to insert.
Return values
CTrieNode*The pointer to the inserted node.
See also
FLImaging::CResult

◆ NormalizeChar()

virtual wchar_t FLImaging::Foundation::CTrie::NormalizeChar ( wchar_t ch) const
protectedvirtual

Normalizes a character to handle case-insensitive search.

Parameters
[in]chThe character to normalize.
Return values
wchar_tThe normalized character.

◆ Remove()

virtual const CResult FLImaging::Foundation::CTrie::Remove ( const std::wstring & wstrWord)
virtual

Removes a word from the Trie.

Parameters
[in]wstrWordThe word to remove.
Return values
constFLImaging::CResult Result of the function.
See also
FLImaging::CResult

◆ RemoveHelper()

virtual bool FLImaging::Foundation::CTrie::RemoveHelper ( CTrieNode * pNode,
const std::wstring & wstrWord,
int32_t i32Depth )
protectedvirtual

Recursively removes a word from the Trie.

Parameters
[in]pNodeThe current node being checked.
[in]wstrWordThe word to remove.
[in]i32DepthThe current depth in recursion.
Return values
trueIf the node should be deleted.

◆ Rename()

virtual CTrieNode * FLImaging::Foundation::CTrie::Rename ( const std::wstring & wstrOldWord,
const std::wstring & wstrNewWord )
virtual

Edits an existing word in the Trie.

Parameters
[in]wstrOldWordThe word to be replaced.
[in]wstrNewWordThe new word to insert.
Return values
CTrieNode*The pointer to the newly inserted node.
constFLImaging::CResult Result of the function.
See also
FLImaging::CResult

◆ SetNodeTemplate()

virtual const CResult FLImaging::Foundation::CTrie::SetNodeTemplate ( const CTrieNode * pTrieNodeTemplate)
virtual

Sets the node template used for creating new nodes.

Parameters
[in]pTrieNodeTemplatePointer to the node template.

Member Data Documentation

◆ m_pNodeTemplate

CTrieNode* FLImaging::Foundation::CTrie::m_pNodeTemplate
protected

The object that serves as a template for nodes. Default is CTrieNode.

◆ m_pRoot

CTrieNode* FLImaging::Foundation::CTrie::m_pRoot
protected

Root node of the Trie.