KTrie< K > Class Template Reference

List of all members.

Public Member Functions

void clear ()
 Clears all set objects in the trie.
bool remove (const char *key)
 Removes a key from the trie.
K * retrieve (const char *key)
 Retrieves a pointer to the object stored at a given key.
bool replace (const char *key, const K &obj)
 Inserts or updates the object stored at a key.
bool insert (const char *key, const K &obj)
 Inserts an object at a key.
void bad_iterator (char *buffer, size_t maxlength, void *data, void(*func)(KTrie *, const char *, K &obj, void *data))
 Iterates over the trie returning all known values.
 KTrie ()
 ~KTrie ()
void run_destructor (void(*dtor)(K *ptr))
size_t mem_usage ()
size_t size ()

Detailed Description

template<typename K>
class KTrie< K >

Definition at line 56 of file sm_trie_tpl.h.


Member Function Documentation

template<typename K>
bool KTrie< K >::remove ( const char *  key  )  [inline]

Removes a key from the trie.

Parameters:
key Key to remove.
Returns:
True on success, false if key was never set.

Definition at line 75 of file sm_trie_tpl.h.

template<typename K>
K* KTrie< K >::retrieve ( const char *  key  )  [inline]

Retrieves a pointer to the object stored at a given key.

Parameters:
key Key to retrieve.
Returns:
Pointer to object, or NULL if key was not found or not set.

Definition at line 97 of file sm_trie_tpl.h.

template<typename K>
bool KTrie< K >::replace ( const char *  key,
const K &  obj 
) [inline]

Inserts or updates the object stored at a key.

Parameters:
key Key to update or insert.
obj Object to store at the key.
Returns:
True on success, false on failure.

Definition at line 114 of file sm_trie_tpl.h.

template<typename K>
bool KTrie< K >::insert ( const char *  key,
const K &  obj 
) [inline]

Inserts an object at a key.

Parameters:
key Key to insert at.
obj Object to store at the key.
Returns:
True on success, false if the key is already set or insertion otherwise failed.

Empty strings are a special case, since there are no productions. We could probably rework it to use BASE[0] but this hack is easier.

Definition at line 140 of file sm_trie_tpl.h.

template<typename K>
void KTrie< K >::bad_iterator ( char *  buffer,
size_t  maxlength,
void *  data,
void(*)(KTrie< K > *, const char *, K &obj, void *data)  func 
) [inline]

Iterates over the trie returning all known values.

Note: This function is for debugging. Do not use it as a production iterator since it's inefficient. Iteration is guaranteed to be sorted ascendingly.

The callback function takes: (KTrie) - Pointer to this Trie (const char *) - String containing key name. (K &) - By-reference object at the key. (data) - User pointer.

Parameters:
buffer Buffer to use as a key name cache.
maxlength Maximum length of the key name buffer.
data User pointer for passing to the iterator.
func Iterator callback function.

Definition at line 670 of file sm_trie_tpl.h.


The documentation for this class was generated from the following file:
Generated on Fri Nov 21 05:10:04 2008 for SourceMod SDK by  doxygen 1.5.1