HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_SymbolMap< T > Class Template Reference

#include <PI_ImportUtils.h>

Classes

class  base_iterator
 Iterator conforming to Houdini's atEnd(), advance() interface. More...
 

Public Types

typedef UT_StringMap< ITEM_T > MapType
 
typedef MapType::const_iterator const_map_iterator
 
typedef MapType::iterator map_iterator
 
typedef ITEM_T value_type
 
typedef base_iterator< ITEM_T,
map_iterator
iterator
 
typedef base_iterator< const
ITEM_T, const_map_iterator
const_iterator
 
typedef const_iterator traverser
 

Public Member Functions

 UT_SymbolMap ()
 Constructor. More...
 
 ~UT_SymbolMap ()
 Destructor. More...
 
void addSymbol (const UT_StringHolder &symbol, const ITEM_T &data)
 Add a symbol to the map. More...
 
bool findSymbol (const UT_StringRef &symbol, ITEM_T *datap) const
 
bool contains (const UT_StringRef &symbol) const
 Check if a symbol exists. More...
 
exint count (const UT_StringRef &symbol) const
 Find out how many times a symbol exists (this will be either 0 or 1). More...
 
bool deleteSymbol (const UT_StringRef &symbol)
 Erase a symbol from the map. More...
 
void clear ()
 
const char * addSymbolAndGetReference (const UT_StringHolder &symbol, const ITEM_T &data)
 Add a symbol and return the string reference. More...
 
bool empty () const
 Check if the map is empty. More...
 
ITEM_T & operator[] (const UT_StringHolder &symbol)
 
ITEM_T & insert (const UT_StringHolder &name, const ITEM_T &item)
 
void reserveTableSize (exint size)
 
float getLoadFactor () const
 Get current load factor. More...
 
void mergeTable (const UT_SymbolMap &table)
 Merge the specified table with ourselves. More...
 
const char * getStringReference (const UT_StringRef &symbol)
 
UT_StringHolder makeUniqueKey (const char *name) const
 Returns a unique key based using the passed-in string as a prefix. More...
 
int64 getMemoryUsage (bool inclusive) const
 Return an approximation of how much memory we use. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_map_iterator map_begin () const
 
const_map_iterator map_end () const
 
map_iterator map_begin ()
 
map_iterator map_end ()
 
UT_IteratorRange
< const_map_iterator
map_range () const
 
UT_IteratorRange< map_iteratormap_range ()
 
void outputStats (std::ostream &os) const
 
map_iterator find (const UT_StringRef &symbol)
 
const_map_iterator find (const UT_StringRef &symbol) const
 
exint erase (const UT_StringRef &symbol)
 
map_iterator erase (const_map_iterator it)
 
exint entries () const
 
exint size () const
 
exint bucket_count () const
 
exint capacity () const
 
float getMaxLoadFactor () const
 
void setMaxLoadFactor (float f)
 
float getMinLoadFactor () const
 
void setMinLoadFactor (float)
 
int traverseConst (int(*function)(ITEM_T &, const char *, void *), void *data) const
 
int traverse (int(*function)(ITEM_T &, const char *, void *), void *data)
 

Protected Attributes

MapType myMap
 

Friends

template<typename OS , typename T >
OS & operator<< (OS &os, const UT_SymbolMap< T > &d)
 

Detailed Description

template<typename T>
class UT_SymbolMap< T >

A UT_SymbolMap contains a UT_Map but provides the interface required by what was UT_SymbolTable. Strings are passed as const char *.

Definition at line 21 of file PI_ImportUtils.h.

Member Typedef Documentation

template<typename T>
typedef base_iterator<const ITEM_T, const_map_iterator> UT_SymbolMap< T >::const_iterator

Definition at line 335 of file UT_SymbolTable.h.

template<typename T>
typedef MapType::const_iterator UT_SymbolMap< T >::const_map_iterator

Definition at line 32 of file UT_SymbolTable.h.

template<typename T>
typedef base_iterator<ITEM_T, map_iterator> UT_SymbolMap< T >::iterator

Definition at line 334 of file UT_SymbolTable.h.

template<typename T>
typedef MapType::iterator UT_SymbolMap< T >::map_iterator

Definition at line 33 of file UT_SymbolTable.h.

template<typename T>
typedef UT_StringMap<ITEM_T> UT_SymbolMap< T >::MapType

Definition at line 31 of file UT_SymbolTable.h.

template<typename T>
typedef const_iterator UT_SymbolMap< T >::traverser

Definition at line 337 of file UT_SymbolTable.h.

template<typename T>
typedef ITEM_T UT_SymbolMap< T >::value_type

Definition at line 34 of file UT_SymbolTable.h.

Constructor & Destructor Documentation

template<typename T>
UT_SymbolMap< T >::UT_SymbolMap ( )
inlineexplicit

Constructor.

Definition at line 37 of file UT_SymbolTable.h.

template<typename T>
UT_SymbolMap< T >::~UT_SymbolMap ( )
inline

Destructor.

Definition at line 42 of file UT_SymbolTable.h.

Member Function Documentation

template<typename T>
void UT_SymbolMap< T >::addSymbol ( const UT_StringHolder symbol,
const ITEM_T &  data 
)
inline

Add a symbol to the map.

Definition at line 48 of file UT_SymbolTable.h.

template<typename T>
const char* UT_SymbolMap< T >::addSymbolAndGetReference ( const UT_StringHolder symbol,
const ITEM_T &  data 
)
inline

Add a symbol and return the string reference.

Definition at line 110 of file UT_SymbolTable.h.

template<typename T>
iterator UT_SymbolMap< T >::begin ( void  )
inline

Definition at line 339 of file UT_SymbolTable.h.

template<typename T>
const_iterator UT_SymbolMap< T >::begin ( void  ) const
inline

Definition at line 341 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::bucket_count ( ) const
inline

Information about the buckets

Definition at line 128 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::capacity ( ) const
inline

Information about the buckets

Definition at line 129 of file UT_SymbolTable.h.

template<typename T>
void UT_SymbolMap< T >::clear ( void  )
inline

Clear the map

Definition at line 104 of file UT_SymbolTable.h.

template<typename T>
bool UT_SymbolMap< T >::contains ( const UT_StringRef symbol) const
inline

Check if a symbol exists.

Definition at line 80 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::count ( const UT_StringRef symbol) const
inline

Find out how many times a symbol exists (this will be either 0 or 1).

Definition at line 83 of file UT_SymbolTable.h.

template<typename T>
bool UT_SymbolMap< T >::deleteSymbol ( const UT_StringRef symbol)
inline

Erase a symbol from the map.

Definition at line 87 of file UT_SymbolTable.h.

template<typename T>
bool UT_SymbolMap< T >::empty ( void  ) const
inline

Check if the map is empty.

Definition at line 134 of file UT_SymbolTable.h.

template<typename T>
iterator UT_SymbolMap< T >::end ( void  )
inline

Definition at line 340 of file UT_SymbolTable.h.

template<typename T>
const_iterator UT_SymbolMap< T >::end ( void  ) const
inline

Definition at line 342 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::entries ( void  ) const
inline

Query the number of elements in the map

Definition at line 122 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::erase ( const UT_StringRef symbol)
inline

Erase a symbol from the map

Definition at line 94 of file UT_SymbolTable.h.

template<typename T>
map_iterator UT_SymbolMap< T >::erase ( const_map_iterator  it)
inline

Erase a symbol from the map

Definition at line 98 of file UT_SymbolTable.h.

template<typename T>
map_iterator UT_SymbolMap< T >::find ( const UT_StringRef symbol)
inline

Find a symbol and return an iterator. Returns map_end() if the symbol is not found in the map.

Definition at line 69 of file UT_SymbolTable.h.

template<typename T>
const_map_iterator UT_SymbolMap< T >::find ( const UT_StringRef symbol) const
inline

Find a symbol and return an iterator. Returns map_end() if the symbol is not found in the map.

Definition at line 73 of file UT_SymbolTable.h.

template<typename T>
bool UT_SymbolMap< T >::findSymbol ( const UT_StringRef symbol,
ITEM_T *  datap 
) const
inline

Find a symbol in the map. If the symbol is found, the data pointer passed in will be assigned to the ITEM_T in the map.

Definition at line 54 of file UT_SymbolTable.h.

template<typename T>
float UT_SymbolMap< T >::getLoadFactor ( ) const
inline

Get current load factor.

Definition at line 156 of file UT_SymbolTable.h.

template<typename T>
float UT_SymbolMap< T >::getMaxLoadFactor ( ) const
inline

Adjust the maximum/minimum load factors The table will automatically rebuild itself to keep the load factor within the specified range. A minimum load factor of 0 means that the table will never shrink when elements are deleted from it.

Definition at line 164 of file UT_SymbolTable.h.

template<typename T>
int64 UT_SymbolMap< T >::getMemoryUsage ( bool  inclusive) const
inline

Return an approximation of how much memory we use.

Definition at line 212 of file UT_SymbolTable.h.

template<typename T>
float UT_SymbolMap< T >::getMinLoadFactor ( ) const
inline

Adjust the maximum/minimum load factors The table will automatically rebuild itself to keep the load factor within the specified range. A minimum load factor of 0 means that the table will never shrink when elements are deleted from it.

Definition at line 168 of file UT_SymbolTable.h.

template<typename T>
const char* UT_SymbolMap< T >::getStringReference ( const UT_StringRef symbol)
inline

"getStringReference" returns a pointer to the actual string that is maintained in the symbol table. This can be used to implement a shared string symbol table.

Definition at line 185 of file UT_SymbolTable.h.

template<typename T>
ITEM_T& UT_SymbolMap< T >::insert ( const UT_StringHolder name,
const ITEM_T &  item 
)
inline

Definition at line 142 of file UT_SymbolTable.h.

template<typename T>
UT_StringHolder UT_SymbolMap< T >::makeUniqueKey ( const char *  name) const
inline

Returns a unique key based using the passed-in string as a prefix.

Definition at line 197 of file UT_SymbolTable.h.

template<typename T>
const_map_iterator UT_SymbolMap< T >::map_begin ( ) const
inline

Definition at line 344 of file UT_SymbolTable.h.

template<typename T>
map_iterator UT_SymbolMap< T >::map_begin ( )
inline

Definition at line 346 of file UT_SymbolTable.h.

template<typename T>
const_map_iterator UT_SymbolMap< T >::map_end ( ) const
inline

Definition at line 345 of file UT_SymbolTable.h.

template<typename T>
map_iterator UT_SymbolMap< T >::map_end ( )
inline

Definition at line 347 of file UT_SymbolTable.h.

template<typename T>
UT_IteratorRange<const_map_iterator> UT_SymbolMap< T >::map_range ( ) const
inline

Definition at line 349 of file UT_SymbolTable.h.

template<typename T>
UT_IteratorRange<map_iterator> UT_SymbolMap< T >::map_range ( )
inline

Definition at line 351 of file UT_SymbolTable.h.

template<typename T>
void UT_SymbolMap< T >::mergeTable ( const UT_SymbolMap< T > &  table)
inline

Merge the specified table with ourselves.

Definition at line 174 of file UT_SymbolTable.h.

template<typename T>
ITEM_T& UT_SymbolMap< T >::operator[] ( const UT_StringHolder symbol)
inline

Retrieve an entry in the table by name, creating it if it doesn't already exist.

Definition at line 138 of file UT_SymbolTable.h.

template<typename T >
void UT_SymbolMap< T >::outputStats ( std::ostream &  os) const

Write out some statistics pertaining to the underlying map container to the output stream given.

Definition at line 366 of file UT_SymbolTable.h.

template<typename T>
void UT_SymbolMap< T >::reserveTableSize ( exint  size)
inline

Call this method when you're adding entries to a table inside a loop and you know how many entries you'll be adding. This will create at least size buckets but also ensure the load factor is less than the maximum load factor.

Definition at line 152 of file UT_SymbolTable.h.

template<typename T>
void UT_SymbolMap< T >::setMaxLoadFactor ( float  f)
inline

Adjust the maximum/minimum load factors The table will automatically rebuild itself to keep the load factor within the specified range. A minimum load factor of 0 means that the table will never shrink when elements are deleted from it.

Definition at line 166 of file UT_SymbolTable.h.

template<typename T>
void UT_SymbolMap< T >::setMinLoadFactor ( float  )
inline

Adjust the maximum/minimum load factors The table will automatically rebuild itself to keep the load factor within the specified range. A minimum load factor of 0 means that the table will never shrink when elements are deleted from it.

Definition at line 170 of file UT_SymbolTable.h.

template<typename T>
exint UT_SymbolMap< T >::size ( void  ) const
inline

Query the number of elements in the map

Definition at line 123 of file UT_SymbolTable.h.

template<typename T>
int UT_SymbolMap< T >::traverse ( int(*)(ITEM_T &, const char *, void *)  function,
void data 
)
inline

"traverse" invokes the given function with every member of the symbol table. The order of traversal is undefined. If the function returns a non-zero value the traversal continues. If it returns zero then traversal stops. The return value is zero if the traversal was interupted and one otherwise.

Call traverseConst() if you will not be removing things from the table while traversing, and traverse() if you might be. It is only safe to remove the current item when using traverse() – not other items. If you call traverse() and add something to the table, you may or may not encounter it later in the traversal.

Definition at line 248 of file UT_SymbolTable.h.

template<typename T>
int UT_SymbolMap< T >::traverseConst ( int(*)(ITEM_T &, const char *, void *)  function,
void data 
) const
inline

"traverse" invokes the given function with every member of the symbol table. The order of traversal is undefined. If the function returns a non-zero value the traversal continues. If it returns zero then traversal stops. The return value is zero if the traversal was interupted and one otherwise.

Call traverseConst() if you will not be removing things from the table while traversing, and traverse() if you might be. It is only safe to remove the current item when using traverse() – not other items. If you call traverse() and add something to the table, you may or may not encounter it later in the traversal.

Definition at line 234 of file UT_SymbolTable.h.

Friends And Related Function Documentation

template<typename T>
template<typename OS , typename T >
OS& operator<< ( OS &  os,
const UT_SymbolMap< T > &  d 
)
friend

Definition at line 377 of file UT_SymbolTable.h.

Member Data Documentation

template<typename T>
MapType UT_SymbolMap< T >::myMap
protected

Definition at line 361 of file UT_SymbolTable.h.


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