HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfDenseHashSet< Element, HashFn, EqualElement, Threshold > Class Template Reference

#include <denseHashSet.h>

Public Types

typedef Element value_type
 
typedef _Vector::const_iterator iterator
 
typedef _Vector::const_iterator const_iterator
 A const_iterator type for this set. More...
 
typedef std::pair
< const_iterator, bool > 
insert_result
 Return type for insert() method. More...
 

Public Member Functions

 TfDenseHashSet (const HashFn &hashFn=HashFn(), const EqualElement &equalElement=EqualElement())
 
 TfDenseHashSet (const TfDenseHashSet &rhs)
 
template<class Iterator >
 TfDenseHashSet (Iterator begin, Iterator end)
 
 TfDenseHashSet (std::initializer_list< Element > l)
 
TfDenseHashSetoperator= (TfDenseHashSet rhs)
 
TfDenseHashSetoperator= (std::initializer_list< Element > l)
 
bool operator== (const TfDenseHashSet &rhs) const
 
bool operator!= (const TfDenseHashSet &rhs) const
 
void clear ()
 
void swap (TfDenseHashSet &rhs)
 
bool empty () const
 
size_t size () const
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator find (const Element &k) const
 
size_t count (const Element &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)
 
size_t erase (const Element &k)
 
void erase (const iterator &iter)
 
void erase (const iterator &i0, const iterator &i1)
 
void shrink_to_fit ()
 
const Element & operator[] (size_t index) const
 

Detailed Description

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
class TfDenseHashSet< Element, HashFn, EqualElement, Threshold >

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

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

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

Definition at line 60 of file denseHashSet.h.

Member Typedef Documentation

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
typedef _Vector::const_iterator TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::const_iterator

A const_iterator type for this set.

Definition at line 86 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
typedef std::pair<const_iterator, bool> TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::insert_result

Return type for insert() method.

Definition at line 89 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
typedef _Vector::const_iterator TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::iterator

An iterator type for this set. Note that this one is const as well, as we can't allow in-place modification of elements due to the potentially allocated hash map.

Definition at line 83 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
typedef Element TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::value_type

Definition at line 64 of file denseHashSet.h.

Constructor & Destructor Documentation

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::TfDenseHashSet ( const HashFn &  hashFn = HashFn(),
const EqualElement &  equalElement = EqualElement() 
)
inlineexplicit

Ctor.

Definition at line 95 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::TfDenseHashSet ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs)
inline

Copy Ctor.

Definition at line 105 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
template<class Iterator >
TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::TfDenseHashSet ( Iterator  begin,
Iterator  end 
)
inline

Construct from range.

Definition at line 114 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::TfDenseHashSet ( std::initializer_list< Element >  l)
inline

Construct from an initializer_list.

Definition at line 120 of file denseHashSet.h.

Member Function Documentation

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
const_iterator TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::begin ( void  ) const
inline

Returns an const_iterator pointing to the beginning of the set.

Definition at line 189 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::clear ( void  )
inline

Erases all of the elements

Definition at line 163 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
size_t TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::count ( const Element &  k) const
inline

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

Definition at line 222 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
bool TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::empty ( void  ) const
inline

true if the set's size is 0.

Definition at line 177 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
const_iterator TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::end ( void  ) const
inline

Returns an const_iterator pointing to the end of the set.

Definition at line 195 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
size_t TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::erase ( const Element &  k)
inline

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

Definition at line 291 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::erase ( const iterator iter)
inline

Erases element pointed to by iter.

Definition at line 303 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::erase ( const iterator i0,
const iterator i1 
)
inline

Erases a range from the set.

Definition at line 328 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
const_iterator TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::find ( const Element &  k) const
inline

Finds the element with key k.

Definition at line 201 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
insert_result TfDenseHashSet< Element, HashFn, EqualElement, 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 229 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
template<class IteratorType >
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::insert ( IteratorType  i0,
IteratorType  i1 
)
inline

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

Definition at line 261 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
template<class Iterator >
void TfDenseHashSet< Element, HashFn, EqualElement, 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 278 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
bool TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::operator!= ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs) const
inline

Definition at line 157 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
TfDenseHashSet& TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::operator= ( TfDenseHashSet< Element, HashFn, EqualElement, Threshold >  rhs)
inline

Assignment operator.

Definition at line 126 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
TfDenseHashSet& TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::operator= ( std::initializer_list< Element >  l)
inline

Assignment from an initializer_list.

Definition at line 133 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
bool TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::operator== ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs) const
inline

Equality operator.

Definition at line 141 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
const Element& TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::operator[] ( size_t  index) const
inline

Index into set via index.

Definition at line 372 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::shrink_to_fit ( )
inline

Optimize storage space.

Definition at line 345 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
size_t TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::size ( void  ) const
inline

Returns the size of the set.

Definition at line 183 of file denseHashSet.h.

template<class Element, class HashFn, class EqualElement = std::equal_to<Element>, unsigned Threshold = 128>
void TfDenseHashSet< Element, HashFn, EqualElement, Threshold >::swap ( TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs)
inline

Swaps the contents of two sets.

Definition at line 170 of file denseHashSet.h.


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