HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Map< K, V, H, P > Class Template Reference

Unsorted map container. More...

#include <UT_Map.h>

+ Inheritance diagram for UT_Map< K, V, H, P >:

Classes

struct  deref_pair_first
 
struct  deref_pair_second
 
class  partial_iterator_base
 

Public Types

typedef hboost::unordered_map
< K, V, H, P
Base
 
typedef Base::key_type key_type
 
typedef Base::mapped_type mapped_type
 
typedef Base::value_type value_type
 
typedef Base::hasher hasher
 
typedef Base::key_equal key_equal
 
typedef Base::iterator iterator
 
typedef Base::const_iterator const_iterator
 
typedef H Hasher
 
typedef P Equal
 
using const_key_iterator = partial_iterator_base< const_iterator, const key_type, deref_pair_first< const_iterator, const key_type >>
 
using mapped_iterator = partial_iterator_base< iterator, mapped_type, deref_pair_second< iterator, mapped_type >>
 
using const_mapped_iterator = partial_iterator_base< const_iterator, const mapped_type, deref_pair_second< const_iterator, const mapped_type >>
 

Public Member Functions

 UT_Map (const Hasher &hf=Hasher(), const Equal &eql=Equal())
 
template<typename InputIt >
 UT_Map (InputIt first, InputIt last, const Hasher &hf=Hasher(), const Equal &eql=Equal())
 
 UT_Map (std::initializer_list< value_type > init_list)
 
int64 getMemoryUsage (bool inclusive) const
 
bool contains (const key_type &key) const
 Returns true if a value with the key is contained in the map. More...
 
get (const key_type &key, const V &defval) const
 
void clear ()
 
UT_IteratorRange
< const_key_iterator
key_range () const
 
UT_IteratorRange< mapped_iteratormapped_range ()
 
UT_IteratorRange
< const_mapped_iterator
mapped_range () const
 

Detailed Description

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
class UT_Map< K, V, H, P >

Unsorted map container.

Examples:
DM/DM_OverdrawHook.C, SIM/SNOW_Solver.C, and SOP/SOP_CustomBrush.C.

Definition at line 107 of file UT_Map.h.

Member Typedef Documentation

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef hboost::unordered_map<K, V, H, P> UT_Map< K, V, H, P >::Base

Definition at line 111 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::const_iterator UT_Map< K, V, H, P >::const_iterator

Definition at line 118 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
using UT_Map< K, V, H, P >::const_key_iterator = partial_iterator_base<const_iterator, const key_type, deref_pair_first<const_iterator, const key_type>>

Definition at line 248 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
using UT_Map< K, V, H, P >::const_mapped_iterator = partial_iterator_base<const_iterator, const mapped_type, deref_pair_second<const_iterator, const mapped_type>>

Definition at line 252 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef P UT_Map< K, V, H, P >::Equal

Definition at line 120 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::hasher UT_Map< K, V, H, P >::hasher

Definition at line 115 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef H UT_Map< K, V, H, P >::Hasher

Definition at line 119 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::iterator UT_Map< K, V, H, P >::iterator

Definition at line 117 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::key_equal UT_Map< K, V, H, P >::key_equal

Definition at line 116 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::key_type UT_Map< K, V, H, P >::key_type

Definition at line 112 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
using UT_Map< K, V, H, P >::mapped_iterator = partial_iterator_base<iterator, mapped_type, deref_pair_second<iterator, mapped_type>>

Definition at line 250 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::mapped_type UT_Map< K, V, H, P >::mapped_type

Definition at line 113 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
typedef Base::value_type UT_Map< K, V, H, P >::value_type

Definition at line 114 of file UT_Map.h.

Constructor & Destructor Documentation

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
UT_Map< K, V, H, P >::UT_Map ( const Hasher hf = Hasher(),
const Equal eql = Equal() 
)
inlineexplicit

Initialize an empty map, and optionally a custom hasher and equal compare functions.

Definition at line 124 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
template<typename InputIt >
UT_Map< K, V, H, P >::UT_Map ( InputIt  first,
InputIt  last,
const Hasher hf = Hasher(),
const Equal eql = Equal() 
)
inline

Initialize the map from an iterator pair, and optionally a custom hasher and equal compare functions.

Definition at line 131 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
UT_Map< K, V, H, P >::UT_Map ( std::initializer_list< value_type init_list)
inline

Initialize the map using an initializer list. The initializer list is a list of pairs of items to add to the map. E.g:

UT_Map<int, const char *> foo = {{1, "one"}, {2, "two"}};

Definition at line 142 of file UT_Map.h.

Member Function Documentation

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
void UT_Map< K, V, H, P >::clear ( void  )
inline

The implementation of clear() is O(bucket_count()), not O(size()), which can cause unexpected performance issues if the map has a large capacity. For std::unordered_map this was defect 2550 (http://cplusplus.github.io/LWG/lwg-defects.html#2550) When updating or changing the underlying implemention, verify if this is still necessary.

Definition at line 184 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
bool UT_Map< K, V, H, P >::contains ( const key_type key) const
inline

Returns true if a value with the key is contained in the map.

Definition at line 159 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
V UT_Map< K, V, H, P >::get ( const key_type key,
const V &  defval 
) const
inline

Returns the value at the key if it exists, or the provided default value if it does not. NOTE: Considering making this return const V&? Don't. Lifetime extension rules likely can't be used to make that safe. eg. const Foo &foo = get(key, Foo()) will return a stale reference.

Definition at line 169 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
int64 UT_Map< K, V, H, P >::getMemoryUsage ( bool  inclusive) const
inline

Returns the approximate size, in bytes, of the memory consumed by this map or, optionally, only the data contained within.

Definition at line 151 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
UT_IteratorRange<const_key_iterator> UT_Map< K, V, H, P >::key_range ( ) const
inline

Returns a range object that iterates over the map but returns only the key values. Example:

UT_Map<int, const char *> foo = {{1, "one"}, {2, "two"}};
for (int key : foo.key_range())
std::cout << key << "\n";

Definition at line 262 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
UT_IteratorRange<mapped_iterator> UT_Map< K, V, H, P >::mapped_range ( )
inline

Returns a range object that iterates over the map but returns only the mapped values.

Definition at line 268 of file UT_Map.h.

template<typename K, typename V, typename H = hboost::hash<K>, typename P = std::equal_to<K>>
UT_IteratorRange<const_mapped_iterator> UT_Map< K, V, H, P >::mapped_range ( ) const
inline

Returns a const range object that iterates over the map but returns only the mapped values.

Definition at line 274 of file UT_Map.h.


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