Code::Blocks
SVN r11506
|
This class is generally a string -> size_t map, the tree details (graph) is already show in the declaration of. More...
#include <searchtree.h>
Public Member Functions | |
BasicSearchTree () | |
virtual | ~BasicSearchTree () |
virtual size_t | size () const |
virtual size_t | GetCount () const |
How many string keys are stored. More... | |
virtual void | clear () |
Gets the number of items stored. More... | |
size_t | insert (const wxString &s) |
Clear items and tree. More... | |
bool | HasItem (const wxString &s) |
Tells if there is an item for string s. More... | |
size_t | count (const wxString &s) |
std::map compatibility for the above More... | |
size_t | GetItemNo (const wxString &s) |
Gets the array position defined by s. More... | |
const wxString | GetString (size_t n) const |
Gets the key string for item n. More... | |
size_t | FindMatches (const wxString &s, std::set< size_t > &result, bool caseSensitive, bool is_prefix) |
Finds items that match a given string. More... | |
wxString | SerializeLabels () |
Serializes the labels into an XML-compatible string. More... | |
wxString | dump () |
Dumps a graphical version of the tree. More... | |
Protected Member Functions | |
virtual SearchTreeNode * | CreateNode (unsigned int depth, nSearchTreeNode parent, nSearchTreeLabel label, unsigned int labelstart, unsigned int labellen) |
Creates a new node. More... | |
wxString | GetString (const SearchTreePoint &nn, nSearchTreeNode top=0) const |
Gets the string corresponding to the tree point 'nn'. More... | |
SearchTreeNode * | GetNode (nSearchTreeNode n, bool NullOnZero=false) |
Obtains the node with number n,NULL if n is invalid. More... | |
bool | FindNode (const wxString &s, nSearchTreeNode nparent, SearchTreePoint *result) |
Finds the node that starts from node 'parent', and has the suffix s. More... | |
SearchTreePoint | AddNode (const wxString &s, nSearchTreeNode nparent=0) |
Adds Suffix s starting from node nparent. More... | |
wxString | SerializeLabel (nSearchTreeLabel labelno) |
Serializes given label into an XML-escaped string. More... | |
Protected Attributes | |
SearchTreeLabelsArray | m_Labels |
Labels used by the nodes' incoming edges. More... | |
SearchTreeNodesArray | m_Nodes |
Nodes array. More... | |
SearchTreePointsArray | m_Points |
Points array. More... | |
Private Member Functions | |
void | CreateRootNode () |
Creates the tree's root node. More... | |
nSearchTreeNode | SplitBranch (nSearchTreeNode n, size_t depth) |
Splits the Branch that leads to node n, at the given depth. More... | |
Friends | |
class | SearchTreeNode |
class | BasicSearchTreeIterator |
This class is generally a string -> size_t map, the tree details (graph) is already show in the declaration of.
Definition at line 276 of file searchtree.h.
BasicSearchTree::BasicSearchTree | ( | ) |
Definition at line 521 of file searchtree.cpp.
|
virtual |
Definition at line 529 of file searchtree.cpp.
|
protected |
Adds Suffix s starting from node nparent.
Definition at line 667 of file searchtree.cpp.
References SearchTreePoint::depth, SearchTreeNode::GetDepth(), SearchTreeNode::GetLabelNo(), SearchTreeNode::GetLabelStart(), SearchTreeNode::GetLabelStartDepth(), SearchTreeNode::IsLeaf(), wxString::length(), SearchTreeNode::m_Children, SearchTreePoint::n, SearchTreeNode::RecalcDepth(), SearchTreeNode::SetLabel(), wxString::Shrink(), wxString::size(), and wxString::substr().
|
virtual |
Gets the number of items stored.
Reimplemented in SearchTree< T >, SearchTree< TokenIdxSet >, and SearchTree< wxString >.
Definition at line 542 of file searchtree.cpp.
Referenced by TokenTree::clear(), SearchTree< wxString >::clear(), and TokenTree::TokenTree().
|
inline |
std::map compatibility for the above
Definition at line 296 of file searchtree.h.
|
protectedvirtual |
Creates a new node.
Function is virtual so the nodes can be extended and customized, or to improve the memory management.
Definition at line 658 of file searchtree.cpp.
References SearchTreeNode::SearchTreeNode().
|
private |
Creates the tree's root node.
Definition at line 843 of file searchtree.cpp.
wxString BasicSearchTree::dump | ( | ) |
Dumps a graphical version of the tree.
Definition at line 1060 of file searchtree.cpp.
References _T.
Referenced by CCDebugInfo::OnSave().
size_t BasicSearchTree::FindMatches | ( | const wxString & | s, |
std::set< size_t > & | result, | ||
bool | caseSensitive, | ||
bool | is_prefix | ||
) |
Finds items that match a given string.
if is_prefix==true, it finds items that start with the string. returns the number of matches.
Definition at line 750 of file searchtree.cpp.
References BasicSearchTreeIterator::Eof(), BasicSearchTreeIterator::FindNext(), SearchTreeNode::GetLabel(), SearchTreeNode::GetLabelLen(), SearchTreeNode::GetLabelStartDepth(), wxString::length(), wxString::Lower(), SearchTreeNode::m_Depth, SearchTreeNode::m_Items, wxString::StartsWith(), and wxString::substr().
Referenced by TokenTree::FindMatches(), and TokenTree::GetFileMatches().
|
protected |
Finds the node that starts from node 'parent', and has the suffix s.
Note that even FindNode return false, the result still be filled with a valid value For example, we have a Node with Label "abc", then we are search the string "abcd" in this Node, Find Node will get false, but the result has pointing to the Node of "abc"
Definition at line 595 of file searchtree.cpp.
References SearchTreePoint::depth, SearchTreeNode::GetChild(), SearchTreeNode::GetDeepestMatchingPosition(), SearchTreeNode::GetDepth(), wxString::IsEmpty(), wxString::length(), and SearchTreePoint::n.
|
inlinevirtual |
How many string keys are stored.
Reimplemented in SearchTree< T >, SearchTree< TokenIdxSet >, and SearchTree< wxString >.
Definition at line 284 of file searchtree.h.
size_t BasicSearchTree::GetItemNo | ( | const wxString & | s | ) |
Gets the array position defined by s.
Definition at line 742 of file searchtree.cpp.
References SearchTreePoint::depth, and SearchTreePoint::n.
Referenced by TokenTree::FindTokensInFile(), TokenTree::GetFileIndex(), SearchTree< wxString >::GetItem(), SearchTree< wxString >::operator[](), TokenTree::RemoveToken(), TokenTree::RenameToken(), and TokenTree::TokenExists().
|
protected |
Obtains the node with number n,NULL if n is invalid.
If NullOnZero == true, returns NULL if n is 0, this forbid returning the root node.
Definition at line 587 of file searchtree.cpp.
References NULL.
Referenced by BasicSearchTreeIterator::BasicSearchTreeIterator(), SearchTreeNode::Dump(), BasicSearchTreeIterator::FindNext(), BasicSearchTreeIterator::FindNextSibling(), BasicSearchTreeIterator::FindPrev(), BasicSearchTreeIterator::FindPrevSibling(), BasicSearchTreeIterator::FindSibling(), SearchTreeNode::GetChild(), SearchTreeNode::Serialize(), and SearchTreeNode::UpdateItems().
const wxString BasicSearchTree::GetString | ( | size_t | n | ) | const |
Gets the key string for item n.
Definition at line 556 of file searchtree.cpp.
References _T.
Referenced by CCDebugInfo::FillFiles(), TokenTree::GetFilename(), and CCDebugInfo::OnSave().
|
protected |
Gets the string corresponding to the tree point 'nn'.
If 'top' is specified, it gets the string that goes from node 'top' to point 'nn'. the default top value is 0, this means we want to get a string from the root to the point
Definition at line 563 of file searchtree.cpp.
References _T, SearchTreePoint::depth, SearchTreeNode::GetDepth(), SearchTreeNode::GetLabel(), SearchTreeNode::GetLabelStartDepth(), SearchTreeNode::GetParent(), and SearchTreePoint::n.
bool BasicSearchTree::HasItem | ( | const wxString & | s | ) |
Tells if there is an item for string s.
Definition at line 734 of file searchtree.cpp.
References wxString::empty(), and SearchTreeNode::GetItemNo().
Referenced by TokenTree::FindTokensInFile().
size_t BasicSearchTree::insert | ( | const wxString & | s | ) |
Clear items and tree.
Adds an item number to position defined by s. If the string already exists, returns the corresponding item no.
Definition at line 822 of file searchtree.cpp.
References SearchTreePoint::depth, and SearchTreePoint::n.
Referenced by SearchTree< wxString >::AddItem(), and TokenTree::InsertFileOrGetIndex().
|
protected |
Serializes given label into an XML-escaped string.
Definition at line 1040 of file searchtree.cpp.
References _T, and SearchTreeNode::SerializeString().
wxString BasicSearchTree::SerializeLabels | ( | ) |
Serializes the labels into an XML-compatible string.
Definition at line 1048 of file searchtree.cpp.
References _T, and SearchTreeNode::U2S().
Referenced by SearchTree< wxString >::Serialize().
|
inlinevirtual |
Reimplemented in SearchTree< T >, SearchTree< TokenIdxSet >, and SearchTree< wxString >.
Definition at line 283 of file searchtree.h.
Referenced by CCDebugInfo::FillFiles(), and CCDebugInfo::OnSave().
|
private |
Splits the Branch that leads to node n, at the given depth.
Used by AddNode.
Definition at line 849 of file searchtree.cpp.
References SearchTreeNode::GetDepth(), SearchTreeNode::GetLabelLen(), SearchTreeNode::GetLabelNo(), SearchTreeNode::GetLabelStart(), SearchTreeNode::GetLabelStartDepth(), SearchTreeNode::GetParent(), SearchTreeNode::m_Children, SearchTreeNode::RecalcDepth(), SearchTreeNode::SetLabel(), SearchTreeNode::SetParent(), and SearchTreeNode::UpdateItems().
|
friend |
Definition at line 279 of file searchtree.h.
|
friend |
Definition at line 278 of file searchtree.h.
|
protected |
Labels used by the nodes' incoming edges.
Definition at line 364 of file searchtree.h.
Referenced by SearchTreeNode::GetActualLabel(), and SearchTreeNode::GetLabel().
|
protected |
Nodes array.
Definition at line 366 of file searchtree.h.
Referenced by BasicSearchTreeIterator::BasicSearchTreeIterator(), SearchTreeNode::GetParent(), BasicSearchTreeIterator::IsValid(), and SearchTree< wxString >::Serialize().
|
protected |
Points array.
Definition at line 368 of file searchtree.h.