HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > Class Template Reference

#include <denseHashMap.h>

Public Types

typedef std::pair< const Key,
Data > 
value_type
 
typedef Key key_type
 
typedef Data mapped_type
 
typedef _IteratorBase
< value_type, typename
_Vector::iterator > 
iterator
 
typedef _IteratorBase< const
value_type, typename
_Vector::const_iterator > 
const_iterator
 
typedef std::pair< iterator, bool > insert_result
 Return type for insert() method. More...
 

Public Member Functions

 TfDenseHashMap (const HashFn &hashFn=HashFn(), const EqualKey &equalKey=EqualKey())
 
template<class Iterator >
 TfDenseHashMap (Iterator begin, Iterator end)
 
 TfDenseHashMap (std::initializer_list< value_type > l)
 
 TfDenseHashMap (const TfDenseHashMap &rhs)
 
 TfDenseHashMap (TfDenseHashMap &&rhs)=default
 
TfDenseHashMapoperator= (const TfDenseHashMap &rhs)
 
TfDenseHashMapoperator= (TfDenseHashMap &&rhs)=default
 
TfDenseHashMapoperator= (std::initializer_list< value_type > l)
 
bool operator== (const TfDenseHashMap &rhs) const
 
bool operator!= (const TfDenseHashMap &rhs) const
 
void clear ()
 
void swap (TfDenseHashMap &rhs)
 
bool empty () const
 
size_t size () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
iterator find (const key_type &k)
 
const_iterator find (const key_type &k) const
 
size_t count (const key_type &k) const
 
insert_result insert (const value_type &v)
 
template<class IteratorType >
void insert (IteratorType i0, IteratorType i1)
 
template<class Iterator >
void insert_unique (Iterator begin, Iterator end)
 
Data & operator[] (const key_type &key)
 
size_t erase (const key_type &k)
 
void erase (const iterator &iter)
 
void erase (iterator i0, iterator i1)
 
void shrink_to_fit ()
 
void reserve (size_t n)
 

Detailed Description

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
class TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >

This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when the size of the map is small.

When the map gets bigger than Threshold a TfHashMap is allocated that is used to accelerate lookup in the vector.

Warning
This differs from a TfHashMap in so far that inserting and removing elements invalidate all iterators of the container.

Definition at line 59 of file denseHashMap.h.

Member Typedef Documentation

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef _IteratorBase<const value_type, typename _Vector::const_iterator> TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::const_iterator

An iterator type for this map. Note that it provides access to the This::value_type only.

Definition at line 211 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef std::pair<iterator, bool> TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::insert_result

Return type for insert() method.

Definition at line 214 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef _IteratorBase<value_type, typename _Vector::iterator> TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::iterator

An iterator type for this map. Note that it provides access to the This::value_type only.

Definition at line 205 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef Key TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::key_type

Definition at line 64 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef Data TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::mapped_type

Definition at line 65 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
typedef std::pair<const Key, Data> TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::value_type

Definition at line 63 of file denseHashMap.h.

Constructor & Destructor Documentation

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::TfDenseHashMap ( const HashFn &  hashFn = HashFn(),
const EqualKey &  equalKey = EqualKey() 
)
inlineexplicit

Ctor.

Definition at line 220 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
template<class Iterator >
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::TfDenseHashMap ( Iterator  begin,
Iterator  end 
)
inline

Construct with range.

Definition at line 231 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::TfDenseHashMap ( std::initializer_list< value_type l)
inline

Construct from an initializer_list.

Definition at line 237 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::TfDenseHashMap ( const TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &  rhs)
inline

Copy Ctor.

Definition at line 243 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::TfDenseHashMap ( TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &&  rhs)
default

Move Ctor.

Member Function Documentation

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::begin ( void  )
inline

Returns an const_iterator pointing to the beginning of the map.

Definition at line 329 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
const_iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::begin ( void  ) const
inline

Returns an const_iterator pointing to the beginning of the map.

Definition at line 341 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::clear ( void  )
inline

Erases all of the elements

Definition at line 303 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
size_t TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::count ( const key_type k) const
inline

Returns the number of elements with key k. Which is either 0 or 1.

Definition at line 381 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
bool TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::empty ( void  ) const
inline

true if the map's size is 0.

Definition at line 317 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::end ( void  )
inline

Returns an const_iterator pointing to the end of the map.

Definition at line 335 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
const_iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::end ( void  ) const
inline

Returns an const_iterator pointing to the end of the map.

Definition at line 347 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
size_t TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::erase ( const key_type k)
inline

Erase element with key k. Returns the number of elements erased.

Definition at line 454 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::erase ( const iterator iter)
inline

Erases element pointed to by iter.

Definition at line 466 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::erase ( iterator  i0,
iterator  i1 
)
inline

Erases a range from the map.

Definition at line 492 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::find ( const key_type k)
inline

Finds the element with key k.

Definition at line 353 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
const_iterator TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::find ( const key_type k) const
inline

Finds the element with key k.

Definition at line 367 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
insert_result TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::insert ( const value_type v)
inline

Returns a pair of <iterator, bool> where iterator points to the element in the list and bool is true if a new element was inserted.

Definition at line 388 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
template<class IteratorType >
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::insert ( IteratorType  i0,
IteratorType  i1 
)
inline

Insert a range into the hash map. Note that i0 and i1 can't point into the hash map.

Definition at line 415 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
template<class Iterator >
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::insert_unique ( Iterator  begin,
Iterator  end 
)
inline

Insert a range of unique elements into the container. [begin, end) must not contain any duplicate elements.

Definition at line 432 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
bool TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator!= ( const TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &  rhs) const
inline

Definition at line 297 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap& TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator= ( const TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &  rhs)
inline

Copy assignment operator.

Definition at line 256 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap& TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator= ( TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &&  rhs)
default

Move assignment operator.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
TfDenseHashMap& TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator= ( std::initializer_list< value_type l)
inline

Assignment from an initializer_list.

Definition at line 270 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
bool TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator== ( const TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &  rhs) const
inline

Equality operator.

Definition at line 278 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
Data& TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::operator[] ( const key_type key)
inline

Indexing operator. Inserts a default constructed DataType() for key if there is no value for key already.

Returns a reference to the value type for key.

Definition at line 448 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::reserve ( size_t  n)
inline

Reserve space.

Definition at line 536 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::shrink_to_fit ( )
inline

Optimize storage space.

Definition at line 510 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
size_t TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::size ( void  ) const
inline

Returns the size of the map.

Definition at line 323 of file denseHashMap.h.

template<class Key, class Data, class HashFn, class EqualKey = std::equal_to<Key>, unsigned Threshold = 128>
void TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold >::swap ( TfDenseHashMap< Key, Data, HashFn, EqualKey, Threshold > &  rhs)
inline

Swaps the contents of two maps.

Definition at line 310 of file denseHashMap.h.


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