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

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. More...

Public Types

typedef Element value_type
 
typedef _Vector::const_iterator iterator
 An iterator type for this set. More...
 
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())
 Ctor. More...
 
 TfDenseHashSet (const TfDenseHashSet &rhs)
 Copy Ctor. More...
 
 TfDenseHashSet (TfDenseHashSet &&rhs)=default
 Move Ctor. More...
 
template<class Iterator >
 TfDenseHashSet (Iterator begin, Iterator end)
 Construct from range. More...
 
 TfDenseHashSet (std::initializer_list< Element > l)
 Construct from an initializer_list. More...
 
TfDenseHashSetoperator= (const TfDenseHashSet &rhs)
 Copy assignment operator. More...
 
TfDenseHashSetoperator= (TfDenseHashSet &&rhs)=default
 Move assignment operator. More...
 
TfDenseHashSetoperator= (std::initializer_list< Element > l)
 Assignment from an initializer_list. More...
 
bool operator== (const TfDenseHashSet &rhs) const
 Equality operator. More...
 
bool operator!= (const TfDenseHashSet &rhs) const
 
void clear ()
 Erases all of the elements. More...
 
void swap (TfDenseHashSet &rhs)
 Swaps the contents of two sets. More...
 
bool empty () const
 true if the set's size is 0. More...
 
size_t size () const
 Returns the size of the set. More...
 
const_iterator begin () const
 Returns an const_iterator pointing to the beginning of the set. More...
 
const_iterator end () const
 Returns an const_iterator pointing to the end of the set. More...
 
const_iterator find (const Element &k) const
 Finds the element with key k. More...
 
size_t count (const Element &k) const
 Returns the number of elements with key k. More...
 
insert_result insert (const value_type &v)
 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. More...
 
template<class IteratorType >
void insert (IteratorType i0, IteratorType i1)
 Insert a range into the hash set. More...
 
template<class Iterator >
void insert_unique (Iterator begin, Iterator end)
 Insert a range of unique elements into the container. More...
 
size_t erase (const Element &k)
 Erase element with key k. More...
 
void erase (const iterator &iter)
 Erases element pointed to by iter. More...
 
void erase (const iterator &i0, const iterator &i1)
 Erases a range from the set. More...
 
void shrink_to_fit ()
 Optimize storage space. More...
 
const Element & operator[] (size_t index) const
 Index into set via index. More...
 

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 58 of file denseHashSet.h.

Member Typedef Documentation

typedef _Vector::const_iterator const_iterator

A const_iterator type for this set.

Definition at line 84 of file denseHashSet.h.

typedef std::pair<const_iterator, bool> insert_result

Return type for insert() method.

Definition at line 87 of file denseHashSet.h.

typedef _Vector::const_iterator 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 81 of file denseHashSet.h.

Constructor & Destructor Documentation

TfDenseHashSet ( const HashFn &  hashFn = HashFn(),
const EqualElement &  equalElement = EqualElement() 
)
inlineexplicit

Ctor.

Definition at line 93 of file denseHashSet.h.

TfDenseHashSet ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs)
inline

Copy Ctor.

Definition at line 103 of file denseHashSet.h.

TfDenseHashSet ( TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &&  rhs)
default

Move Ctor.

TfDenseHashSet ( Iterator  begin,
Iterator  end 
)
inline

Construct from range.

Definition at line 117 of file denseHashSet.h.

TfDenseHashSet ( std::initializer_list< Element >  l)
inline

Construct from an initializer_list.

Definition at line 123 of file denseHashSet.h.

Member Function Documentation

const_iterator begin ( ) const
inline

Returns an const_iterator pointing to the beginning of the set.

Definition at line 199 of file denseHashSet.h.

void clear ( )
inline

Erases all of the elements.

Definition at line 173 of file denseHashSet.h.

size_t count ( const Element &  k) const
inline

Returns the number of elements with key k.

Which is either 0 or 1.

Definition at line 232 of file denseHashSet.h.

bool empty ( ) const
inline

true if the set's size is 0.

Definition at line 187 of file denseHashSet.h.

const_iterator end ( ) const
inline

Returns an const_iterator pointing to the end of the set.

Definition at line 205 of file denseHashSet.h.

size_t erase ( const Element &  k)
inline

Erase element with key k.

Returns the number of elements erased.

Definition at line 301 of file denseHashSet.h.

void erase ( const iterator iter)
inline

Erases element pointed to by iter.

Definition at line 313 of file denseHashSet.h.

void erase ( const iterator i0,
const iterator i1 
)
inline

Erases a range from the set.

Definition at line 338 of file denseHashSet.h.

const_iterator find ( const Element &  k) const
inline

Finds the element with key k.

Definition at line 211 of file denseHashSet.h.

insert_result 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 239 of file denseHashSet.h.

void 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 271 of file denseHashSet.h.

void 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 288 of file denseHashSet.h.

TfDenseHashSet& operator= ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs)
inline

Copy assignment operator.

Definition at line 129 of file denseHashSet.h.

TfDenseHashSet& operator= ( TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &&  rhs)
default

Move assignment operator.

TfDenseHashSet& operator= ( std::initializer_list< Element >  l)
inline

Assignment from an initializer_list.

Definition at line 143 of file denseHashSet.h.

bool operator== ( const TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs) const
inline

Equality operator.

Definition at line 151 of file denseHashSet.h.

const Element& operator[] ( size_t  index) const
inline

Index into set via index.

Definition at line 381 of file denseHashSet.h.

void shrink_to_fit ( )
inline

Optimize storage space.

Definition at line 355 of file denseHashSet.h.

size_t size ( ) const
inline

Returns the size of the set.

Definition at line 193 of file denseHashSet.h.

void swap ( TfDenseHashSet< Element, HashFn, EqualElement, Threshold > &  rhs)
inline

Swaps the contents of two sets.

Definition at line 180 of file denseHashSet.h.


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