36 template <
typename DataT,
typename HashT = HashFn<DataT> >
73 SetVector(
const ContainerType& other) : m_vector( other.m_vector ), m_hash( other.m_hash )
80 ContainerType&
operator= (
const ContainerType& other)
82 if (
this == &other ) {
86 m_vector = other.m_vector;
87 m_hash = other.m_hash;
122 return m_vector.
size();
130 return m_vector.
empty();
147 template<
typename T2 >
152 typename HashType::iterator it = m_hash.
find(data);
153 if (it != m_hash.
end())
156 m_vector[it->second] = data;
157 return &m_vector[it->second];
181 template<
typename T2 >
199 template<
typename OldDataT,
typename NewDataT >
200 iterator
replace(
const OldDataT& oldData,
const NewDataT& newData )
204 auto oldIt = m_hash.
find( oldData );
205 if ( oldIt == m_hash.
end() )
208 size_t index = oldIt->second;
209 m_vector[ index ] = newData;
210 m_hash.
erase( oldIt );
211 m_hash.
insert( newData, index );
213 return begin() + index;
224 template<
typename T2 >
240 template<
typename T2 >
245 typename HashType::iterator it = m_hash.
find( key );
246 if (it == m_hash.
end())
249 return &m_vector[it->second];
259 template<
typename T2 >
260 const_iterator
find(
const T2& key)
const 264 typename HashType::const_iterator it = m_hash.
find( key );
265 if (it == m_hash.
end())
269 return &m_vector[it->second];
280 return m_vector.
begin();
290 return m_vector.
begin();
306 inline const_reverse_iterator
rbegin()
const 320 return m_vector.
end();
326 inline const_iterator
end()
const 329 return m_vector.
end();
339 return m_vector.
rend(); }
344 inline const_reverse_iterator
rend()
const 347 return m_vector.
rend();
374 return m_vector[m_vector.
size()-1];
380 inline const DataT&
back()
const 383 return m_vector[m_vector.
size()-1];
396 template<
typename T2 >
401 typename HashType::iterator it = m_hash.
find( key );
402 if (it == m_hash.
end())
432 typename HashType::iterator hashIt = m_hash.
find( key );
488 inline const DataT&
at(
size_t index)
const 490 return m_vector.
at(index);
499 inline DataT&
at(
size_t index)
501 return m_vector.
at(index);
550 #if 0 // Slower implementation 551 typename VectorType savedElements;
554 for(; it != m_vector.
end(); ++it)
573 #else // Faster implementation 588 return removeElements.
size();
596 return m_vector.
size() == m_hash.
size();
599 void erase(
typename HashType::iterator it )
601 size_t idx = it->second;
606 if (m_vector.
size() > 1 && idx != (m_vector.
size()-1))
612 m_vector[idx] = lastElement;
618 m_hash.
insert( lastElement, idx );
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements.
iterator find(const KeyT &key)
Find a key/value pair in the hash table given a key.
const HashType & table() const
SetVector(const ContainerType &other)
Copy constructor.
HashTable< DataT, size_t, HashT > HashType
void clear(int policy=SHRINK_BUFFER_AVERAGED)
Remove all elements.
VectorType::const_iterator const_iterator
const DataT & front() const
void reserve(size_t size)
Reserve capacity in the hash table.
iterator replace(const OldDataT &oldData, const NewDataT &newData)
Replace data in set vector.
const_reverse_iterator rbegin() const
ClearPolicy
agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control...
const VectorType & vector() const
std::reverse_iterator< const_iterator > const_reverse_iterator
VectorType::iterator iterator
const DataT & const_reference
bool empty() const
Return true if the container is empty.
const DataT & back() const
reverse_iterator rbegin()
ContainerType & operator=(const ContainerType &other)
Assignment operator.
void reserve(size_t size)
Reserve capacity in the vector.
const_iterator find(const T2 &key) const
Perform a hash search for a given key.
Buffer is deallocated and replaced by an newly allocated empty buffer.
bool erase(const iterator &it)
Erase an element using an iterator.
reverse_iterator rbegin()
void reserve(size_t num_elems)
Make room for this many elements in the hash table.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
T & at(size_t index) const
const_iterator begin() const
void clear(ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
Remove all elements, optionally with maintained buffer allocation.
bool contains(const KeyT &k) const
Check if the hash table contains a key/value pair for the given key.
iterator end()
Iterator marking end of hash table.
DataT & operator[](size_t i)
Access an element in the vector using an index.
Smart pointer for handling referenced counted objects.
const DataT & operator[](size_t i) const
Access an element in the vector using an index.
bool erase(const KeyT &key)
Erase an element from the hash table.
DataT & at(size_t index)
Access an element in the vector using an index.
iterator insert(const KeyT &key, const ValueT value)
Insert a key/value pair into the hash table.
VectorType::reverse_iterator reverse_iterator
const_reverse_iterator rend() const
VectorType::const_reverse_iterator const_reverse_iterator
Buffer is shrunk if a smoothing average (which is updated each clear call) goes below a threshold...
size_t size() const
Return the number of inserted elements.
const DataT & at(size_t index) const
Access an element in the vector using an index.
iterator insert(const T2 &data)
Insert a data element in to the end of the container.
SetVector< DataT, HashT > ContainerType
const_iterator end() const
Inheritance with partial specialization due to bug with ref_ptr containers.
std::reverse_iterator< iterator > reverse_iterator
Vector< DataT > VectorType
Buffer is maintained (normal stl behavior).
iterator find(const T2 &key)
Perform a hash search for a given key.
bool contains(const T2 &key) const
Hash search for the data in the container.
void push_back(const T2 &value)
size_t purge(T purger)
Purge the hash set.
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
bool erase(const T2 &key)
Erase an element from the container.
iterator push_back(const T2 &data)
Insert a data element in to the end of the container.