11 #ifndef __UT_SymbolTable_h__
12 #define __UT_SymbolTable_h__
29 template <
typename ITEM_T>
54 (*this)[symbol] =
data;
61 if (it !=
myMap.end())
75 return myMap.find(symbol);
79 return myMap.find(symbol);
85 {
return myMap.count(symbol) > 0; }
88 {
return myMap.count(symbol); }
120 return myMap.find(symbol)->first.c_str();
144 return myMap[symbol];
149 return ((*
this)[name] = item);
157 {
myMap.rehash(size); }
161 {
return myMap.load_factor(); }
169 {
return myMap.max_load_factor(); }
171 {
myMap.max_load_factor(f); }
183 (*
this)[it->first] = it->second;
197 return it->first.c_str();
218 int64 mem = inclusive ?
sizeof(*this) : 0;
222 mem += it->first.getMemoryUsage(
false);
239 int (*
function)(ITEM_T &,
const char *,
void *),
244 if (!
function(const_cast<ITEM_T &>(it->second),
245 it->first.c_str(),
data))
252 int traverse(
int (*
function)(ITEM_T &,
const char *,
void *),
262 if (!
function(curr->second, curr->first.c_str(),
data))
272 template<
typename T,
typename IT>
288 template<
typename ET,
typename EIT>
290 : myIt(src.myIt), myEnd(src.myEnd) {}
299 {
return myIt->first; }
305 return myIt == cmp.myIt;
308 {
return !(*
this ==
cmp); }
312 return myIt == myEnd;
333 typedef base_iterator<ITEM_T, map_iterator>
iterator;
357 template<
typename OS,
typename T>
358 friend OS &operator<<(OS &os, const UT_SymbolMap<T> &d);
364 namespace UT_SymbolTableDetail
373 float min_load_factor,
374 float max_load_factor);
377 template <
typename T>
382 os,
size(), bucket_count(), capacity(),
383 getLoadFactor(), getMinLoadFactor(), getMaxLoadFactor());
386 template<
typename OS,
typename T>
388 operator<<(OS &os, const UT_SymbolMap<T> &d)
void adoptFromString(UT_String &str)
ITEM_T & operator[](const UT_StringHolder &symbol)
UT_IteratorRange< map_iterator > map_range()
ITEM_T & insert(const UT_StringHolder &name, const ITEM_T &item)
int64 getMemoryUsage(bool inclusive) const
void setMinLoadFactor(float)
UT_IteratorRange< IterT > UTmakeRange(IterT &&b, IterT &&e)
void setMaxLoadFactor(float f)
int64 getMemoryUsage(bool inclusive) const
Return an approximation of how much memory we use.
const_map_iterator find(const UT_StringRef &symbol) const
void outputStats(std::ostream &os) const
bool operator==(const base_iterator< T, IT > &cmp) const
base_iterator(const base_iterator< ET, EIT > &src)
int traverseConst(int(*function)(ITEM_T &, const char *, void *), void *data) const
MapType::const_iterator const_map_iterator
Parent::iterator iterator
base_iterator< const ITEM_T, const_map_iterator > const_iterator
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
base_iterator< ITEM_T, map_iterator > iterator
const char * name() const
UT_StringHolder makeUniqueKey(const char *name) const
Returns a unique key based using the passed-in string as a prefix.
void reserveTableSize(exint size)
exint erase(const UT_StringRef &symbol)
std::forward_iterator_tag iterator_category
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
~UT_SymbolMap()
Destructor.
iterator erase(const_iterator pos)
base_iterator & operator++()
map_iterator find(const UT_StringRef &symbol)
std::ptrdiff_t difference_type
SYS_FORCE_INLINE const char * c_str() const
GLuint const GLchar * name
Iterator conforming to Houdini's atEnd(), advance() interface.
UT_StringMap< ITEM_T > MapType
bool contains(const UT_StringRef &symbol) const
Check if a symbol exists.
int traverse(int(*function)(ITEM_T &, const char *, void *), void *data)
exint count(const UT_StringRef &symbol) const
Find out how many times a symbol exists (this will be either 0 or 1).
Parent::const_iterator const_iterator
GLenum GLenum GLsizei void * table
bool empty() const
Check if the map is empty.
map_iterator erase(const_map_iterator it)
void mergeTable(const UT_SymbolMap &table)
Merge the specified table with ourselves.
void incrementNumberedName(bool preserve_padding=false)
const_iterator end() const
UT_API void outputStats(std::ostream &os, exint size, exint bucket_count, exint capacity, float load_factor, float min_load_factor, float max_load_factor)
__hostdev__ uint64_t last(uint32_t i) const
const_map_iterator map_begin() const
UT_SymbolMap()
Constructor.
const_map_iterator map_end() const
const_iterator begin() const
const UT_StringHolder & key() const
pointer operator->() const
SYS_FORCE_INLINE bool UTisstring(const char *s)
const char * addSymbolAndGetReference(const UT_StringHolder &symbol, const ITEM_T &data)
Add a symbol and return the string reference.
bool findSymbol(const UT_StringRef &symbol, ITEM_T *datap) const
bool operator!=(const base_iterator< T, IT > &cmp) const
UT_IteratorRange< const_map_iterator > map_range() const
bool deleteSymbol(const UT_StringRef &symbol)
Erase a symbol from the map.
const char * getStringReference(const UT_StringRef &symbol)
reference operator*() const
float getMaxLoadFactor() const
MapType::iterator map_iterator
float getLoadFactor() const
Get current load factor.
void addSymbol(const UT_StringHolder &symbol, const ITEM_T &data)
Add a symbol to the map.
exint bucket_count() const
float getMinLoadFactor() const