AGXDynamics  2.31.1.0
agx::HashSetImplementation< KeyT, HashT, AllocatorT > Class Template Reference

Same as hash table, but only containing keys, not key-value pairs. More...

#include <HashSet.h>

+ Inheritance diagram for agx::HashSetImplementation< KeyT, HashT, AllocatorT >:

Classes

class  Bucket
 
class  insert_iterator
 
class  template_iterator
 

Public Types

enum  ClearPolicy { SHRINK_BUFFER, SHRINK_BUFFER_AVERAGED, MAINTAIN_BUFFER }
 agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control what should become of the container's memory. More...
 
typedef template_iterator< const HashSetImplementation< KeyT, HashT, AllocatorT > > const_iterator
 
typedef const KeyT * const_pointer
 
typedef const KeyT & const_reference
 
typedef size_t difference_type
 
typedef template_iterator< HashSetImplementation< KeyT, HashT, AllocatorT > > iterator
 Iterators. More...
 
typedef std::bidirectional_iterator_tag iterator_category
 
typedef KeyT * pointer
 
typedef KeyT & reference
 
typedef size_t size_type
 
typedef KeyT value_type
 

Public Member Functions

 HashSetImplementation (const AllocatorT &allocator=AllocatorT())
 Constructor. More...
 
 HashSetImplementation (const HashSetImplementation< KeyT, HashT, AllocatorT > &other)
 Copy constructor. More...
 
 ~HashSetImplementation ()
 Destructor. More...
 
AllocatorT & allocator ()
 
const AllocatorT & allocator () const
 
iterator begin ()
 Iterator to first element in hash set. More...
 
const_iterator begin () const
 
size_t capacity () const
 Returns the size of the memory are used by the container to store its elements. More...
 
void clear (ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
 Remove all elements. More...
 
bool contains (const KeyT &key) const
 Boolean query to test existence of an element. More...
 
bool empty () const
 
iterator end ()
 Iterator marking end of hash set. More...
 
const_iterator end () const
 
bool erase (const KeyT &key)
 Erase an element from the hash set. More...
 
iterator erase (const iterator &it)
 Erase an element using an iterator. More...
 
iterator find (const KeyT &key)
 Find an element. More...
 
const_iterator find (const KeyT &key) const
 
insert_iterator insert (const KeyT &key)
 Insert an element, overwriting if key already exists. More...
 
HashSetImplementation< KeyT, HashT, AllocatorT > & operator= (const HashSetImplementation< KeyT, HashT, AllocatorT > &other)
 Assignment operator. More...
 
KeyT & operator[] (const KeyT &key)
 Index operator for accessing elements in the hash, inserting it if not found. More...
 
const KeyT & operator[] (const KeyT &key) const
 
void * ptr ()
 
const void * ptr () const
 
template<typename T >
void purge (T purger)
 Purge the hash set. More...
 
void reserve (size_t size)
 Reserve capacity in the hash set. More...
 
size_t size () const
 

Protected Member Functions

Bucket * buckets () const
 
bool eraseBucket (size_t index)
 
template<typename T2 >
size_t findBucket (const T2 &key) const
 
size_t & numBuckets ()
 
size_t numBuckets () const
 
size_t & numFilled ()
 
size_t numFilled () const
 
void rebuild (size_t size)
 Rebuild, and optionally resize hash set. More...
 

Protected Attributes

void * m_buffer
 
size_t m_capacity
 
size_t m_size
 

Detailed Description

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
class agx::HashSetImplementation< KeyT, HashT, AllocatorT >

Same as hash table, but only containing keys, not key-value pairs.

Definition at line 49 of file HashSet.h.

Member Typedef Documentation

◆ const_iterator

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef template_iterator< const HashSetImplementation<KeyT, HashT, AllocatorT> > agx::HashSetImplementation< KeyT, HashT, AllocatorT >::const_iterator

Definition at line 178 of file HashSet.h.

◆ const_pointer

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef const KeyT* agx::HashSetImplementation< KeyT, HashT, AllocatorT >::const_pointer

Definition at line 54 of file HashSet.h.

◆ const_reference

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef const KeyT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::const_reference

Definition at line 56 of file HashSet.h.

◆ difference_type

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef size_t agx::HashSetImplementation< KeyT, HashT, AllocatorT >::difference_type

Definition at line 59 of file HashSet.h.

◆ iterator

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef template_iterator< HashSetImplementation<KeyT, HashT, AllocatorT> > agx::HashSetImplementation< KeyT, HashT, AllocatorT >::iterator

Iterators.

Definition at line 177 of file HashSet.h.

◆ iterator_category

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef std::bidirectional_iterator_tag agx::HashSetImplementation< KeyT, HashT, AllocatorT >::iterator_category

Definition at line 58 of file HashSet.h.

◆ pointer

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef KeyT* agx::HashSetImplementation< KeyT, HashT, AllocatorT >::pointer

Definition at line 53 of file HashSet.h.

◆ reference

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef KeyT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::reference

Definition at line 55 of file HashSet.h.

◆ size_type

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef size_t agx::HashSetImplementation< KeyT, HashT, AllocatorT >::size_type

Definition at line 57 of file HashSet.h.

◆ value_type

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef KeyT agx::HashSetImplementation< KeyT, HashT, AllocatorT >::value_type

Definition at line 52 of file HashSet.h.

Member Enumeration Documentation

◆ ClearPolicy

agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control what should become of the container's memory.

Enumerator
SHRINK_BUFFER 

Buffer is deallocated and replaced by an newly allocated empty buffer.

SHRINK_BUFFER_AVERAGED 

Buffer is shrunk if a smoothing average (which is updated each clear call) goes below a threshold.

MAINTAIN_BUFFER 

Buffer is maintained (normal stl behavior).

Definition at line 42 of file Container.h.

Constructor & Destructor Documentation

◆ HashSetImplementation() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
agx::HashSetImplementation< KeyT, HashT, AllocatorT >::HashSetImplementation ( const AllocatorT &  allocator = AllocatorT())
inline

Constructor.

Definition at line 208 of file HashSet.h.

◆ HashSetImplementation() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
agx::HashSetImplementation< KeyT, HashT, AllocatorT >::HashSetImplementation ( const HashSetImplementation< KeyT, HashT, AllocatorT > &  other)
inline

Copy constructor.

Definition at line 212 of file HashSet.h.

◆ ~HashSetImplementation()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
agx::HashSetImplementation< KeyT, HashT, AllocatorT >::~HashSetImplementation ( )
inline

Destructor.

Definition at line 233 of file HashSet.h.

Member Function Documentation

◆ allocator() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
AllocatorT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::allocator ( )
inline

Definition at line 484 of file HashSet.h.

◆ allocator() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const AllocatorT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::allocator ( ) const
inline

Definition at line 485 of file HashSet.h.

◆ begin() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::begin ( )
inline

Iterator to first element in hash set.

Definition at line 356 of file HashSet.h.

Referenced by agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=().

◆ begin() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const_iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::begin ( ) const
inline

Definition at line 359 of file HashSet.h.

◆ buckets()

◆ capacity()

size_t agx::Container::capacity ( ) const
inherited

Returns the size of the memory are used by the container to store its elements.

Some types of containers, e.g. the agx::Vector, will not do a reallocation until the size of the container reaches the capacity. However, this is not the case for e.g., agx::HashTable, which may perform a reallocation earlier.

Returns
The size of the allocated memory area, in number of elements.

Definition at line 135 of file Container.h.

References agx::Container::m_capacity.

Referenced by agx::Vector< WireContactConstraintRef >::operator=().

◆ clear()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
void agx::HashSetImplementation< KeyT, HashT, AllocatorT >::clear ( ClearPolicy  policy = SHRINK_BUFFER_AVERAGED)
inline

Remove all elements.

Definition at line 395 of file HashSet.h.

Referenced by agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=().

◆ contains()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
bool agx::HashSetImplementation< KeyT, HashT, AllocatorT >::contains ( const KeyT &  key) const
inline

Boolean query to test existence of an element.

Definition at line 310 of file HashSet.h.

Referenced by agx::createMissingTiers().

◆ empty()

bool agx::Container::empty ( ) const
inherited

◆ end() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::end ( )
inline

◆ end() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const_iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::end ( ) const
inline

Definition at line 369 of file HashSet.h.

◆ erase() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
bool agx::HashSetImplementation< KeyT, HashT, AllocatorT >::erase ( const KeyT &  key)
inline

Erase an element from the hash set.

Returns
false if element was not found

Definition at line 377 of file HashSet.h.

◆ erase() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::erase ( const iterator &  it)
inline

Erase an element using an iterator.

Returns
An iterator to the next element

Definition at line 386 of file HashSet.h.

◆ eraseBucket()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
bool agx::HashSetImplementation< KeyT, HashT, AllocatorT >::eraseBucket ( size_t  index)
inlineprotected

◆ find() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::find ( const KeyT &  key)
inline

◆ find() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const_iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::find ( const KeyT &  key) const
inline

Definition at line 347 of file HashSet.h.

◆ findBucket()

◆ insert()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
insert_iterator agx::HashSetImplementation< KeyT, HashT, AllocatorT >::insert ( const KeyT &  key)
inline

◆ numBuckets() [1/2]

◆ numBuckets() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
size_t agx::HashSetImplementation< KeyT, HashT, AllocatorT >::numBuckets ( ) const
inlineprotected

Definition at line 524 of file HashSet.h.

◆ numFilled() [1/2]

◆ numFilled() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
size_t agx::HashSetImplementation< KeyT, HashT, AllocatorT >::numFilled ( ) const
inlineprotected

Definition at line 525 of file HashSet.h.

◆ operator=()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
HashSetImplementation<KeyT, HashT, AllocatorT>& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::operator= ( const HashSetImplementation< KeyT, HashT, AllocatorT > &  other)
inline

Assignment operator.

Definition at line 218 of file HashSet.h.

◆ operator[]() [1/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
KeyT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::operator[] ( const KeyT &  key)
inline

Index operator for accessing elements in the hash, inserting it if not found.

Parameters
key- The key to look for
Returns
reference to the matching data.

Definition at line 321 of file HashSet.h.

◆ operator[]() [2/2]

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const KeyT& agx::HashSetImplementation< KeyT, HashT, AllocatorT >::operator[] ( const KeyT &  key) const
inline

Definition at line 330 of file HashSet.h.

◆ ptr() [1/2]

void * agx::Container::ptr ( )
inherited
Returns
Pointer to the container's memory area.

Definition at line 137 of file Container.h.

References agx::Container::m_buffer.

◆ ptr() [2/2]

const void * agx::Container::ptr ( ) const
inherited

Definition at line 138 of file Container.h.

References agx::Container::m_buffer.

◆ purge()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
template<typename T >
void agx::HashSetImplementation< KeyT, HashT, AllocatorT >::purge ( T  purger)
inline

Purge the hash set.

Good to use when removing multiple items, since iterators are invalidated after any modification. The purger should be a functor class which takes the key as parameter and return true if the entry should be removed from the hash set.

Definition at line 466 of file HashSet.h.

◆ rebuild()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
void agx::HashSetImplementation< KeyT, HashT, AllocatorT >::rebuild ( size_t  size)
inlineprotected

◆ reserve()

template<typename KeyT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
void agx::HashSetImplementation< KeyT, HashT, AllocatorT >::reserve ( size_t  size)
inline

Reserve capacity in the hash set.

Definition at line 451 of file HashSet.h.

Referenced by agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=().

◆ size()

size_t agx::Container::size ( ) const
inherited
Returns
The number of elements in the container.

Definition at line 134 of file Container.h.

References agx::Container::m_size.

Referenced by agxCollide::GroupFooCollider< ShapeType >::_calculateContacts(), agxData::Array< JacobianElementT >::Array(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::back(), agx::MemoryPoolOld< T >::clear(), agxData::BufferT< T >::commit(), agxSDK::copyVectors(), agx::createMissingTiers(), agxCollide::Space::disableForContacts(), agxSDK::LinkedSegmentIterator< T >::end(), agxSDK::LinkedSegmentIterator< T >::findPrevIndex(), agx::ConstraintImplementation::findSecondaryConstraintGivenType(), agx::MemoryPoolOld< T >::garbageCollect(), agx::ConstraintImplementation::BodyView::getNumBodies(), agx::ConstraintImplementation::SolverBodyView::getPermutedBodyAt(), agxSDK::LinkedSegmentIterator< T >::isEnd(), agxPowerLine::ConnectionIterator< T >::isValid(), agxPowerLine::PhysicalDimensionIterator< UnitPtr >::isValid(), agx::Vector< WireContactConstraintRef >::operator!=(), agx::VectorPOD< agx::Vec6 >::operator!=(), agxSDK::LinkedSegmentIterator< T >::operator+(), agxPowerLine::PhysicalDimensionIterator< UnitPtr >::operator++(), agxSDK::LinkedSegmentIterator< T >::operator-(), agx::Vector< WireContactConstraintRef >::operator=(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::operator=(), agx::VectorPOD< agx::Vec6 >::operator=(), agx::Vector< WireContactConstraintRef >::operator==(), agx::VectorPOD< agx::Vec6 >::operator==(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::operator[](), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::operator[](), agxOSG::RenderStateManager::parseUniform(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::push_back(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::rebuild(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::rebuild(), agxRender::HeightFieldProxy::setHeights(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::size(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::size(), agxVehicle::utils::splitNonconsecutive(), agxWire::transformPointToShape(), agxWire::transformPointToWorld(), agxWire::transformVectorToShape(), agxWire::transformVectorToWorld(), agxModel::triangleIterator(), agx::Event::trigger(), and agxStream::StoreObjects< T >::~StoreObjects().

Member Data Documentation

◆ m_buffer

◆ m_capacity

◆ m_size


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