Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SearchTree< T > Class Template Reference

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>

Inheritance diagram for SearchTree< T >:
Collaboration diagram for SearchTree< T >:

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...
 
GetItem (const wxString &s)
 Gets the item at position defined by key string s. More...
 
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 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

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

Detailed Description

template<class T>
class SearchTree< T >

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.

Constructor & Destructor Documentation

◆ SearchTree()

template<class T >
SearchTree< T >::SearchTree ( )

Definition at line 420 of file searchtree.h.

◆ ~SearchTree()

template<class T >
SearchTree< T >::~SearchTree ( )
virtual

Definition at line 426 of file searchtree.h.

Member Function Documentation

◆ AddFirstNullItem()

template<class T >
bool SearchTree< T >::AddFirstNullItem ( )
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().

◆ AddItem()

template<class T>
size_t SearchTree< T >::AddItem ( const wxString s,
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().

◆ clear()

template<class T >
void SearchTree< T >::clear ( )
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().

◆ ClearItems()

template<class T >
void SearchTree< T >::ClearItems ( )
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().

◆ GetCount()

template<class T >
size_t SearchTree< T >::GetCount ( ) const
virtual

Clears the tree.

Reimplemented from BasicSearchTree.

Definition at line 438 of file searchtree.h.

◆ GetItem() [1/2]

template<class T >
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().

◆ GetItem() [2/2]

template<class T >
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.

◆ GetItemAtPos()

template<class T >
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().

◆ LoadCacheFrom()

template<class T >
bool SearchTree< T >::LoadCacheFrom ( const wxString filename)

Stores the Tree and items into a file.

Definition at line 455 of file searchtree.h.

◆ operator[]()

template<class T >
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.

◆ SaveCacheTo()

template<class T >
bool SearchTree< T >::SaveCacheTo ( const wxString filename)

Same as GetCount.

Definition at line 450 of file searchtree.h.

◆ Serialize()

template<class T >
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().

◆ SerializeItem()

template<class T>
virtual wxString SearchTree< T >::SerializeItem ( cb_unused size_t  idx)
inlinevirtual

Serializes the stored items.

Definition at line 405 of file searchtree.h.

Referenced by SearchTree< wxString >::Serialize().

◆ SetItemAtPos()

template<class T>
void SearchTree< T >::SetItemAtPos ( size_t  i,
item 
)

Replaces the item found at position(index) i.

Definition at line 495 of file searchtree.h.

◆ size()

template<class T >
size_t SearchTree< T >::size ( ) const
virtual

Gets the number of items stored.

Reimplemented from BasicSearchTree.

Definition at line 444 of file searchtree.h.

◆ UnserializeItem()

template<class T>
virtual void* SearchTree< T >::UnserializeItem ( cb_unused const wxString s)
inlinevirtual

Unserializes the items to be stored.

Definition at line 408 of file searchtree.h.

Member Data Documentation

◆ m_Items

template<class T>
std::vector<T> SearchTree< T >::m_Items
protected

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