Code::Blocks
SVN r11506
|
this is a class template derived from BasicSearchTree class, the type T was stored in a vector, and instead of returning a item number, the new class template can return an instance of T. More...
#include <searchtree.h>
Public Member Functions | |
SearchTree () | |
virtual | ~SearchTree () |
virtual void | clear () |
Gets the number of items stored. More... | |
size_t | GetCount () const |
Clears the tree. More... | |
virtual size_t | size () const |
Gets the number of items stored. More... | |
bool | SaveCacheTo (const wxString &filename) |
Same as GetCount. More... | |
bool | LoadCacheFrom (const wxString &filename) |
Stores the Tree and items into a file. More... | |
wxString | Serialize () |
Loads the Tree and items from a file. More... | |
T | GetItem (const wxString &s) |
Gets the item at position defined by key string s. More... | |
T | GetItem (const wxChar *s) |
the key string can be specified by a wxChar array More... | |
size_t | AddItem (const wxString &s, T item, bool replaceexisting=false) |
Adds an item to position defined by s and return the item number. More... | |
T & | GetItemAtPos (size_t i) |
Gets the item found at position i, the i is the item index. More... | |
void | SetItemAtPos (size_t i, T item) |
Replaces the item found at position(index) i. More... | |
T & | operator[] (const wxString &s) |
Gets the item found at position s. More... | |
virtual wxString | SerializeItem (cb_unused size_t idx) |
Serializes the stored items. More... | |
virtual void * | UnserializeItem (cb_unused const wxString &s) |
Unserializes the items to be stored. More... | |
Public Member Functions inherited from BasicSearchTree | |
BasicSearchTree () | |
virtual | ~BasicSearchTree () |
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 void | ClearItems () |
The actual stored items. More... | |
virtual bool | AddFirstNullItem () |
Adds a null item to position 0. More... | |
Protected Member Functions inherited from BasicSearchTree | |
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 | |
std::vector< T > | m_Items |
Protected Attributes inherited from BasicSearchTree | |
SearchTreeLabelsArray | m_Labels |
Labels used by the nodes' incoming edges. More... | |
SearchTreeNodesArray | m_Nodes |
Nodes array. More... | |
SearchTreePointsArray | m_Points |
Points array. More... | |
this is a class template derived from BasicSearchTree class, the type T was stored in a vector, and instead of returning a item number, the new class template can return an instance of T.
So, basically, you can regard this class as a map of key string -> T
Definition at line 374 of file searchtree.h.
SearchTree< T >::SearchTree | ( | ) |
Definition at line 420 of file searchtree.h.
|
virtual |
Definition at line 426 of file searchtree.h.
|
protectedvirtual |
Adds a null item to position 0.
Definition at line 506 of file searchtree.h.
Referenced by SearchTree< wxString >::clear(), and SearchTree< wxString >::SearchTree().
size_t SearchTree< T >::AddItem | ( | const wxString & | s, |
T | item, | ||
bool | replaceexisting = false |
||
) |
Adds an item to position defined by s and return the item number.
Definition at line 474 of file searchtree.h.
Referenced by TokenTree::AddToken(), ParserBase::FindFirstFileInIncludeDirs(), SearchTree< wxString >::operator[](), and TokenTree::RenameToken().
|
virtual |
Gets the number of items stored.
Reimplemented from BasicSearchTree.
Definition at line 431 of file searchtree.h.
Referenced by TokenTree::clear(), and TokenTree::TokenTree().
|
protectedvirtual |
The actual stored items.
Called by BasicSearchTree::BasicSearchTree() and BasicSearchTree::Clear()
Releases the stored items (vector) from memory. Called by Clear();
Definition at line 501 of file searchtree.h.
Referenced by SearchTree< wxString >::clear(), and SearchTree< wxString >::~SearchTree().
|
virtual |
T SearchTree< T >::GetItem | ( | const wxString & | s | ) |
Gets the item at position defined by key string s.
Definition at line 466 of file searchtree.h.
Referenced by ParserBase::FindFirstFileInIncludeDirs(), and SearchTree< wxString >::GetItem().
T SearchTree< T >::GetItem | ( | const wxChar * | s | ) |
the key string can be specified by a wxChar array
Definition at line 460 of file searchtree.h.
T & SearchTree< T >::GetItemAtPos | ( | size_t | i | ) |
Gets the item found at position i, the i is the item index.
Definition at line 488 of file searchtree.h.
Referenced by TokenTree::AddToken(), TokenTree::FindMatches(), SearchTree< wxString >::GetItem(), TokenTree::RemoveToken(), TokenTree::RenameToken(), and TokenTree::TokenExists().
bool SearchTree< T >::LoadCacheFrom | ( | const wxString & | filename | ) |
Stores the Tree and items into a file.
Definition at line 455 of file searchtree.h.
T & SearchTree< T >::operator[] | ( | const wxString & | s | ) |
Gets the item found at position s.
Inserts new empty one if not found.
Definition at line 513 of file searchtree.h.
bool SearchTree< T >::SaveCacheTo | ( | const wxString & | filename | ) |
Same as GetCount.
Definition at line 450 of file searchtree.h.
wxString SearchTree< T >::Serialize | ( | ) |
Loads the Tree and items from a file.
Definition at line 525 of file searchtree.h.
Referenced by CCDebugInfo::OnSave(), and SearchTree< wxString >::Serialize().
|
inlinevirtual |
Serializes the stored items.
Definition at line 405 of file searchtree.h.
Referenced by SearchTree< wxString >::Serialize().
void SearchTree< T >::SetItemAtPos | ( | size_t | i, |
T | item | ||
) |
Replaces the item found at position(index) i.
Definition at line 495 of file searchtree.h.
|
virtual |
Gets the number of items stored.
Reimplemented from BasicSearchTree.
Definition at line 444 of file searchtree.h.
|
inlinevirtual |
Unserializes the items to be stored.
Definition at line 408 of file searchtree.h.
|
protected |
Definition at line 411 of file searchtree.h.
Referenced by SearchTree< wxString >::AddFirstNullItem(), SearchTree< wxString >::AddItem(), SearchTree< wxString >::ClearItems(), SearchTree< wxString >::GetCount(), SearchTree< wxString >::GetItemAtPos(), SearchTree< wxString >::operator[](), SearchTree< wxString >::SearchTree(), SearchTree< wxString >::Serialize(), SearchTree< wxString >::SetItemAtPos(), and SearchTree< wxString >::size().