|
AGX Dynamics
2.35.0.1
|
This class is a combined container which has the find complexity of a HashTable, deterministic iteration of a Vector (using begin(), end()). More...
#include <SetVector.h>
Public Types | |
| enum | ClearPolicy { SHRINK_BUFFER =VectorType::SHRINK_BUFFER , SHRINK_BUFFER_AVERAGED =VectorType::SHRINK_BUFFER_AVERAGED , MAINTAIN_BUFFER =VectorType::MAINTAIN_BUFFER } |
| typedef VectorType::const_iterator | const_iterator |
| typedef const DataT & | const_reference |
| typedef VectorType::const_reverse_iterator | const_reverse_iterator |
| typedef SetVector< DataT, HashT > | ContainerType |
| typedef HashTable< DataT, size_t, HashT > | HashType |
| typedef VectorType::iterator | iterator |
| typedef VectorType::reverse_iterator | reverse_iterator |
| typedef size_t | size_type |
| typedef DataT | value_type |
| typedef Vector< DataT > | VectorType |
Public Member Functions | |
| SetVector () | |
| Constructor. More... | |
| SetVector (const ContainerType &other) | |
| Copy constructor. More... | |
| ~SetVector () | |
| Destructor. More... | |
| DataT & | at (size_t index) |
| Access an element in the vector using an index. More... | |
| const DataT & | at (size_t index) const |
| Access an element in the vector using an index. More... | |
| DataT & | back () |
| const DataT & | back () const |
| iterator | begin () |
| const_iterator | begin () const |
| void | clear (ClearPolicy policy=SHRINK_BUFFER_AVERAGED) |
| Remove all elements. More... | |
| template<typename T2 > | |
| bool | contains (const T2 &key) const |
| Hash search for the data in the container. More... | |
| bool | empty () const |
| Return true if the container is empty. More... | |
| iterator | end () |
| const_iterator | end () const |
| bool | erase (const iterator &it) |
| Erase an element using an iterator. More... | |
| template<typename T2 > | |
| bool | erase (const T2 &key) |
| Erase an element from the container. More... | |
| template<typename T2 > | |
| iterator | find (const T2 &key) |
| Perform a hash search for a given key. More... | |
| template<typename T2 > | |
| const_iterator | find (const T2 &key) const |
| Perform a hash search for a given key. More... | |
| DataT & | front () |
| const DataT & | front () const |
| template<typename T2 > | |
| iterator | insert (const T2 &data) |
| Insert a data element in to the end of the container. More... | |
| ContainerType & | operator= (const ContainerType &other) |
| Assignment operator. More... | |
| DataT & | operator[] (size_t i) |
| Access an element in the vector using an index. More... | |
| const DataT & | operator[] (size_t i) const |
| Access an element in the vector using an index. More... | |
| template<typename T > | |
| size_t | purge (T purger) |
| Purge the hash set. More... | |
| template<typename T2 > | |
| iterator | push_back (const T2 &data) |
| Insert a data element in to the end of the container. More... | |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| template<typename OldDataT , typename NewDataT > | |
| iterator | replace (const OldDataT &oldData, const NewDataT &newData) |
| Replace data in set vector. More... | |
| void | reserve (size_t size) |
| Reserve capacity in the hash table. More... | |
| size_t | size () const |
| Return the number of inserted elements. More... | |
| const HashType & | table () const |
| const VectorType & | vector () const |
This class is a combined container which has the find complexity of a HashTable, deterministic iteration of a Vector (using begin(), end()).
The cost is storage requirement. Data is stored in a vector<pair<KeyT, DataT> >, which contains the Hash key and the data. A hash table in parallel store the index to the vector and the corresponding key.
Beware of accessing the iterator of the vector, and change the Key value (pair.first). This will effectively invalidate the data structure. Unfortunately, there is no easy way protecting this unless only a const_iterator is used for accessing the vector, which would reduce the practical functionality of the container.
Definition at line 37 of file SetVector.h.
| typedef VectorType::const_iterator agx::SetVector< DataT, HashT >::const_iterator |
Definition at line 63 of file SetVector.h.
| typedef const DataT& agx::SetVector< DataT, HashT >::const_reference |
Definition at line 42 of file SetVector.h.
| typedef VectorType::const_reverse_iterator agx::SetVector< DataT, HashT >::const_reverse_iterator |
Definition at line 65 of file SetVector.h.
| typedef SetVector<DataT, HashT> agx::SetVector< DataT, HashT >::ContainerType |
Definition at line 44 of file SetVector.h.
| typedef HashTable<DataT, size_t, HashT> agx::SetVector< DataT, HashT >::HashType |
Definition at line 46 of file SetVector.h.
| typedef VectorType::iterator agx::SetVector< DataT, HashT >::iterator |
Definition at line 62 of file SetVector.h.
| typedef VectorType::reverse_iterator agx::SetVector< DataT, HashT >::reverse_iterator |
Definition at line 64 of file SetVector.h.
| typedef size_t agx::SetVector< DataT, HashT >::size_type |
Definition at line 43 of file SetVector.h.
| typedef DataT agx::SetVector< DataT, HashT >::value_type |
Definition at line 41 of file SetVector.h.
| typedef Vector<DataT> agx::SetVector< DataT, HashT >::VectorType |
Definition at line 45 of file SetVector.h.
| enum agx::SetVector::ClearPolicy |
| Enumerator | |
|---|---|
| SHRINK_BUFFER | |
| SHRINK_BUFFER_AVERAGED | |
| MAINTAIN_BUFFER | |
Definition at line 54 of file SetVector.h.
|
inline |
Constructor.
Definition at line 69 of file SetVector.h.
|
inline |
Copy constructor.
Definition at line 73 of file SetVector.h.
References agx::SetVector< DataT, HashT >::clear(), and agx::SetVector< DataT, HashT >::SHRINK_BUFFER.
|
inline |
Destructor.
Definition at line 89 of file SetVector.h.
References agx::SetVector< DataT, HashT >::clear(), and agx::SetVector< DataT, HashT >::MAINTAIN_BUFFER.
|
inline |
Access an element in the vector using an index.
Definition at line 495 of file SetVector.h.
References agx::Vector< T, Allocator >::at().
|
inline |
Access an element in the vector using an index.
Definition at line 484 of file SetVector.h.
References agx::Vector< T, Allocator >::at().
Referenced by agxRender::RigidBodyBatchRenderProxy::set().
|
inline |
Definition at line 367 of file SetVector.h.
References agxAssert, and agx::Container::size().
|
inline |
Definition at line 376 of file SetVector.h.
References agxAssert, and agx::Container::size().
|
inline |
Definition at line 272 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::begin().
Referenced by agxWire::WireController::getBeginWireIterator(), agx::Frame::removeAllChildren(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Definition at line 282 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::begin().
|
inline |
Remove all elements.
| policy | - specifies the erase policy. |
Definition at line 442 of file SetVector.h.
References agxAssert, agx::Vector< T, Allocator >::clear(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clear().
Referenced by agx::SetVector< DataT, HashT >::SetVector(), agx::SetVector< DataT, HashT >::~SetVector(), and agx::Frame::removeAllChildren().
|
inline |
Hash search for the data in the container.
Complexity: O(HashTable::contains())
Definition at line 221 of file SetVector.h.
References agxAssert, and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::contains().
Referenced by agxCollide::Space::canCollide(), and agxSDK::matchFilter().
|
inline |
Return true if the container is empty.
Definition at line 124 of file SetVector.h.
References agx::Container::empty().
Referenced by agx::Frame::hasChildren(), and agx::SetVector< DataT, HashT >::purge().
|
inline |
Definition at line 312 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::end().
Referenced by agx::SetVector< DataT, HashT >::erase(), agx::SetVector< DataT, HashT >::find(), agx::SetVector< DataT, HashT >::push_back(), agx::Frame::removeAllChildren(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Definition at line 322 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::end().
|
inline |
Erase an element using an iterator.
This method assumes that it is a valid/existing iterator in the container. If it is not, there is a chance that the iterator is point at something we do not want to touch, hence could cause crash. it is checked to see if it is == end(), then the method will return false. For other invalid iterators, behavior is undefined.
Complexity: O(HashTable::find() + HashTable::erase() + Vector::fastErase() )
| it | - Iterator to the element to be removed. |
Definition at line 418 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), agx::SetVector< DataT, HashT >::end(), agx::SetVector< DataT, HashT >::erase(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find().
|
inline |
Erase an element from the container.
The elements in the vector CAN change order due to the use of Vector::fastErase, where the erased and the last element swap places.
Complexity: O(HashTable::find() + HashTable::erase() + Vector::fastErase() )
Definition at line 393 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find().
Referenced by agx::SetVector< DataT, HashT >::erase(), agx::SetVector< DataT, HashT >::purge(), and agx::Frame::removeChild().
|
inline |
Perform a hash search for a given key.
Complexity: O(HashTable::find())
Definition at line 237 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), agx::SetVector< DataT, HashT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find().
|
inline |
Perform a hash search for a given key.
Complexity: O(HashTable::find())
Definition at line 256 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), agx::SetVector< DataT, HashT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find().
|
inline |
Definition at line 349 of file SetVector.h.
References agxAssert.
|
inline |
Definition at line 358 of file SetVector.h.
References agxAssert.
|
inline |
Insert a data element in to the end of the container.
The element will end up at the end of the vector (analogue to a vector push_back!). What also happens is an insert into the hash table.
Identical to the push_back() method
Complexity: O(HashTable::find()+HashTable::insert()+Vector::push_back())
Definition at line 178 of file SetVector.h.
References agxAssert, and agx::SetVector< DataT, HashT >::push_back().
|
inline |
Assignment operator.
Definition at line 80 of file SetVector.h.
|
inline |
Access an element in the vector using an index.
Definition at line 458 of file SetVector.h.
References agxAssert, and agx::Container::size().
|
inline |
Access an element in the vector using an index.
Definition at line 470 of file SetVector.h.
References agxAssert, and agx::Container::size().
|
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.
Complexity N - size of container, n - number of purged elements: O(n*HashTable::erase())
Example of a purger implementation:
template < typename T1, typename T2 > class MyPurger { public: MyPurger() {} inline bool operator()(const T1& a, const T2& b) { return a > b; } };
| purger | - An instance of a class with an bool () operator which when it returns true, the element will be removed from the container |
Definition at line 541 of file SetVector.h.
References agx::Vector< T, Allocator >::begin(), agx::Vector< T, Allocator >::clear(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clear(), agx::SetVector< DataT, HashT >::empty(), agx::Vector< T, Allocator >::end(), agx::SetVector< DataT, HashT >::erase(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::Vector< T, Allocator >::push_back(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reserve(), agx::Vector< T, Allocator >::reserve(), agx::Container::SHRINK_BUFFER_AVERAGED, and agx::Container::size().
|
inline |
Insert a data element in to the end of the container.
The element will end up at the end of the vector (analogue to a vector push_back!). What also happens is an insert into the hash table.
If the data already exists in the Container, it will analogue to the HashTable replace the already existing data element in the vector.
Identical to the insert() method
Complexity: O(HashTable::find()+HashTable::insert()+Vector::push_back())
Definition at line 144 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), agx::SetVector< DataT, HashT >::end(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::Vector< T, Allocator >::push_back(), and agx::Container::size().
Referenced by agx::SetVector< DataT, HashT >::insert().
|
inline |
Definition at line 292 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::rbegin().
|
inline |
Definition at line 302 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::rbegin().
|
inline |
Definition at line 331 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::rend().
|
inline |
Definition at line 340 of file SetVector.h.
References agxAssert, and agx::Vector< T, Allocator >::rend().
|
inline |
Replace data in set vector.
Similar to erase + insert but preserve iteration order.
oldData doesn't exist, the operation is aborted and end() is returned. | oldData | - old key (fails if not present in this hash vector) |
| newData | - new key for data |
Definition at line 196 of file SetVector.h.
References agxAssert, agx::SetVector< DataT, HashT >::begin(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), agx::SetVector< DataT, HashT >::end(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert().
|
inline |
Reserve capacity in the hash table.
| size | - reserve size elements |
Definition at line 505 of file SetVector.h.
References agxAssert, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reserve(), agx::Vector< T, Allocator >::reserve(), and agx::SetVector< DataT, HashT >::size().
|
inline |
Return the number of inserted elements.
Definition at line 114 of file SetVector.h.
References agxAssert, and agx::Container::size().
Referenced by agx::MergeSplitBodyStorage::getNumChildren(), agx::MergeSplitBodyStorage::hasChildren(), agx::SetVector< DataT, HashT >::reserve(), and agxRender::RigidBodyBatchRenderProxy::set().
|
inline |
Definition at line 106 of file SetVector.h.
|
inline |
Definition at line 98 of file SetVector.h.