AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT > Class Template Reference

A simple hash table using quadratic probing. More...

#include <QuadraticProbingHashTable.h>

+ Inheritance diagram for agx::QuadraticProbingHashTableImplementation< KeyT, DataT, 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
QuadraticProbingHashTableImplementation
< KeyT, DataT, HashT,
AllocatorT > > 
const_iterator
 
typedef HashT hash_fn_type
 
typedef template_iterator
< QuadraticProbingHashTableImplementation
< KeyT, DataT, HashT,
AllocatorT > > 
iterator
 Iterators. More...
 
typedef KeyT key_type
 
typedef DataT value_type
 

Public Member Functions

 QuadraticProbingHashTableImplementation (const AllocatorT &allocator=AllocatorT())
 Constructor. More...
 
 QuadraticProbingHashTableImplementation (const QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT > &other)
 Copy constructor. More...
 
 ~QuadraticProbingHashTableImplementation ()
 Destructor. More...
 
AllocatorT & allocator ()
 
const AllocatorT & allocator () const
 
iterator begin ()
 Iterator to first element in hash table. 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 table. More...
 
const_iterator end () const
 
bool erase (const KeyT &key)
 Erase an element from the hash table. 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
 
const Bucket * getBucketBuffer () const
 
size_t getMaxProbeLength () const
 
size_t getNumBuckets () const
 
DataT & getOrCreate (const KeyT &key)
 Returns value given key. More...
 
insert_iterator insert (const KeyT &key, const DataT &data)
 Insert an element, overwriting if key already exists. More...
 
QuadraticProbingHashTableImplementation
< KeyT, DataT, HashT,
AllocatorT > & 
operator= (const QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT > &other)
 Assignment operator. More...
 
DataT & operator[] (const KeyT &key)
 Index operator for accessing elements in the hash, inserting it if not found. More...
 
const DataT & operator[] (const KeyT &key) const
 
void * ptr ()
 
const void * ptr () const
 
template<typename T >
void purge (T purger)
 Purge the hash table. More...
 
void reserve (size_t size)
 Reserve capacity in the hash table. 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 table. More...
 

Protected Attributes

void * m_buffer
 
size_t m_capacity
 
size_t m_size
 

Detailed Description

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

A simple hash table using quadratic probing.

Built-in support for keys of type int, agx::String, and pointers. To use other types of keys, a custom hash functor must be supplied.

\todo implement [] operator

Definition at line 47 of file QuadraticProbingHashTable.h.

Member Typedef Documentation

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

Definition at line 228 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef HashT agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::hash_fn_type

Definition at line 52 of file QuadraticProbingHashTable.h.

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

Iterators.

Definition at line 227 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
typedef KeyT agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::key_type

Definition at line 51 of file QuadraticProbingHashTable.h.

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

Definition at line 50 of file QuadraticProbingHashTable.h.

Member Enumeration Documentation

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

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

Constructor.

Definition at line 259 of file QuadraticProbingHashTable.h.

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

Copy constructor.

Definition at line 263 of file QuadraticProbingHashTable.h.

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

Destructor.

Definition at line 285 of file QuadraticProbingHashTable.h.

Member Function Documentation

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

Definition at line 565 of file QuadraticProbingHashTable.h.

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

Definition at line 566 of file QuadraticProbingHashTable.h.

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

Definition at line 422 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
Bucket* agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::buckets ( ) const
inlineprotected
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< T, Allocator >::operator=().

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
void agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::clear ( ClearPolicy  policy = SHRINK_BUFFER_AVERAGED)
inline
template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
bool agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::contains ( const KeyT &  key) const
inline

Boolean query to test existence of an element.

Definition at line 397 of file QuadraticProbingHashTable.h.

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

Definition at line 432 of file QuadraticProbingHashTable.h.

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

Erase an element from the hash table.

Returns
false if element was not found

Definition at line 440 of file QuadraticProbingHashTable.h.

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

Erase an element using an iterator.

Returns
An iterator to the next element

Definition at line 449 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
bool agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::eraseBucket ( size_t  index)
inlineprotected
template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
iterator agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::find ( const KeyT &  key)
inline
template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const_iterator agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::find ( const KeyT &  key) const
inline

Definition at line 410 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
const Bucket* agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::getBucketBuffer ( ) const
inline

Definition at line 573 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
size_t agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::getMaxProbeLength ( ) const
inline

Definition at line 574 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
size_t agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::getNumBuckets ( ) const
inline

Definition at line 575 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
DataT& agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::getOrCreate ( const KeyT &  key)
inline

Returns value given key.

If the key doesn't exist, the key is inserted and the default value is returned.

Parameters
key- key
Returns
data for key

Definition at line 321 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
size_t& agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::numBuckets ( )
inlineprotected

Definition at line 583 of file QuadraticProbingHashTable.h.

Referenced by agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::clear(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::contains(), agx::QuadraticProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::contains(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::end(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::eraseBucket(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::findBucket(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::getNumBuckets(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::insert(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::purge(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::rebuild(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::reserve(), and agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::~QuadraticProbingHashTableImplementation().

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

Definition at line 587 of file QuadraticProbingHashTable.h.

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

Definition at line 588 of file QuadraticProbingHashTable.h.

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

Assignment operator.

Definition at line 269 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
DataT& agx::QuadraticProbingHashTableImplementation< KeyT, DataT, 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 299 of file QuadraticProbingHashTable.h.

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

Definition at line 308 of file QuadraticProbingHashTable.h.

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.

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

Definition at line 138 of file Container.h.

References agx::Container::m_buffer.

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

Purge the hash table.

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 and value as parameters and return true if the pair should be removed from the hash table.

Definition at line 543 of file QuadraticProbingHashTable.h.

template<typename KeyT, typename DataT, typename HashT = HashFn<KeyT>, typename AllocatorT = ByteAllocator>
void agx::QuadraticProbingHashTableImplementation< KeyT, DataT, HashT, AllocatorT >::reserve ( size_t  size)
inline
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< T >::Array(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::back(), agx::SetVector< const agxPowerLine::Unit * >::back(), agx::WireContactConstraint::calculateD(), agx::WireContactConstraint::calculateRHS(), agx::GlobalResult::Transaction::commit(), agxData::BufferT< T >::commit(), agxSDK::copyVectors(), agx::createMissingTiers(), agxCollide::Space::disableForContacts(), agxSDK::LinkedSegmentIterator< T >::end(), agx::ConstraintImplementation::findSecondaryConstraintGivenType(), agxSDK::MergeSplitThresholds::get(), agx::WireContactConstraint::getForceOnParticle(), agxSDK::MultiCollisionFilterContactHandler::getGeometryContact(), agxModel::HeightController::getHeight(), agx::WireContactConstraint::getInvMass(), agx::WireContactConstraint::getJacobian(), agx::WireContactConstraint::getMass(), agx::ConstraintImplementation::BodyView::getNumBodies(), agxSDK::LinkedStructure::getNumSegments(), agxIO::MeshReader::getNumTriangles(), agxSDK::MergeSplitThresholds::getNumValues(), agxSDK::LinkedStructure::getSegment(), agxSDK::CollisionGroupFilter::hasMemberGroup(), agxSDK::CollisionGroupFilter::match(), agx::Vector< T, Allocator >::operator!=(), agx::VectorPOD< T, Allocator >::operator!=(), agx::Vector< T, Allocator >::operator=(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::operator=(), agx::VectorPOD< T, Allocator >::operator=(), agx::Vector< T, Allocator >::operator==(), agx::VectorPOD< T, Allocator >::operator==(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::operator[](), agx::SetVector< const agxPowerLine::Unit * >::operator[](), agxOSG::RenderStateManager::parseUniform(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< const agxPowerLine::Unit * >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< const agxPowerLine::Unit * >::push_back(), agxIO::ArgumentParser::read1(), agxIO::ArgumentParser::read2(), agxIO::ArgumentParser::read3(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::rebuild(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::rebuild(), agxRender::HeightFieldProxy::setHeights(), agxUtil::ConvexHull2D::size(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::size(), agx::SetVector< const agxPowerLine::Unit * >::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


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