Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
BasicSearchTree Class Reference

This class is generally a string -> size_t map, the tree details (graph) is already show in the declaration of. More...

#include <searchtree.h>

Inheritance diagram for BasicSearchTree:
Collaboration diagram for BasicSearchTree:

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 SearchTreeNodeCreateNode (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...
 
SearchTreeNodeGetNode (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
 

Detailed Description

This class is generally a string -> size_t map, the tree details (graph) is already show in the declaration of.

See also
SearchTreeNode and
BasicSearchTreeIterator.

Definition at line 276 of file searchtree.h.

Constructor & Destructor Documentation

◆ BasicSearchTree()

BasicSearchTree::BasicSearchTree ( )

Definition at line 521 of file searchtree.cpp.

◆ ~BasicSearchTree()

BasicSearchTree::~BasicSearchTree ( )
virtual

Definition at line 529 of file searchtree.cpp.

Member Function Documentation

◆ AddNode()

SearchTreePoint BasicSearchTree::AddNode ( const wxString s,
nSearchTreeNode  nparent = 0 
)
protected

◆ clear()

void BasicSearchTree::clear ( )
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().

◆ count()

size_t BasicSearchTree::count ( const wxString s)
inline

std::map compatibility for the above

Definition at line 296 of file searchtree.h.

◆ CreateNode()

SearchTreeNode * BasicSearchTree::CreateNode ( unsigned int  depth,
nSearchTreeNode  parent,
nSearchTreeLabel  label,
unsigned int  labelstart,
unsigned int  labellen 
)
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().

◆ CreateRootNode()

void BasicSearchTree::CreateRootNode ( )
private

Creates the tree's root node.

Definition at line 843 of file searchtree.cpp.

◆ dump()

wxString BasicSearchTree::dump ( )

Dumps a graphical version of the tree.

Definition at line 1060 of file searchtree.cpp.

References _T.

Referenced by CCDebugInfo::OnSave().

◆ FindMatches()

size_t BasicSearchTree::FindMatches ( const wxString s,
std::set< size_t > &  result,
bool  caseSensitive,
bool  is_prefix 
)

◆ FindNode()

bool BasicSearchTree::FindNode ( const wxString s,
nSearchTreeNode  nparent,
SearchTreePoint result 
)
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.

◆ GetCount()

virtual size_t BasicSearchTree::GetCount ( ) const
inlinevirtual

How many string keys are stored.

Reimplemented in SearchTree< T >, SearchTree< TokenIdxSet >, and SearchTree< wxString >.

Definition at line 284 of file searchtree.h.

◆ GetItemNo()

size_t BasicSearchTree::GetItemNo ( const wxString s)

◆ GetNode()

SearchTreeNode * BasicSearchTree::GetNode ( nSearchTreeNode  n,
bool  NullOnZero = false 
)
protected

◆ GetString() [1/2]

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().

◆ GetString() [2/2]

wxString BasicSearchTree::GetString ( const SearchTreePoint nn,
nSearchTreeNode  top = 0 
) const
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.

◆ HasItem()

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().

◆ insert()

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().

◆ SerializeLabel()

wxString BasicSearchTree::SerializeLabel ( nSearchTreeLabel  labelno)
protected

Serializes given label into an XML-escaped string.

Definition at line 1040 of file searchtree.cpp.

References _T, and SearchTreeNode::SerializeString().

◆ SerializeLabels()

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().

◆ size()

virtual size_t BasicSearchTree::size ( ) const
inlinevirtual

◆ SplitBranch()

nSearchTreeNode BasicSearchTree::SplitBranch ( nSearchTreeNode  n,
size_t  depth 
)
private

Splits the Branch that leads to node n, at the given depth.

Used by AddNode.

Returns
the newly created node if the given position is exactly the length of n's vertex, just return n.

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().

Friends And Related Function Documentation

◆ BasicSearchTreeIterator

friend class BasicSearchTreeIterator
friend

Definition at line 279 of file searchtree.h.

◆ SearchTreeNode

friend class SearchTreeNode
friend

Definition at line 278 of file searchtree.h.

Member Data Documentation

◆ m_Labels

SearchTreeLabelsArray BasicSearchTree::m_Labels
protected

Labels used by the nodes' incoming edges.

Definition at line 364 of file searchtree.h.

Referenced by SearchTreeNode::GetActualLabel(), and SearchTreeNode::GetLabel().

◆ m_Nodes

SearchTreeNodesArray BasicSearchTree::m_Nodes
protected

◆ m_Points

SearchTreePointsArray BasicSearchTree::m_Points
protected

Points array.

Definition at line 368 of file searchtree.h.


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