RobWorkProject  24.12.4-
Public Member Functions | List of all members
PairMap< T1, T2 > Class Template Reference

a specialized mapping implementation for pairs. It uses the internal structure of template T1 to provide fast O(1) lookup for mappings from a Pair to anything. The order of the Pairs does not matter. More...

#include <PairMap.hpp>

Inherited by FramePairMap< int >, and FramePairMap< std::vector< rwsim::dynamics::ContactManifold > >.

Public Member Functions

 PairMap ()
 creates a map
 
 PairMap (const T2 &defaultVal)
 creates a map with an initial size of s More...
 
void insert (const Pair &pair, const T2 &value)
 inserts a value into the map More...
 
bool has (const Pair &pair) const
 True iff a value for frame has been inserted in the map (or accessed using non-const operator[]).
 
bool has (const T1 f1, const T1 f2) const
 True iff a value for frame has been inserted in the map (or accessed using operator[]). More...
 
const T2 & operator[] (const Pair &pair) const
 return a reference to the value that is associated with the pair pair. More...
 
const T2 & operator() (T1 f1, T1 f2) const
 return a reference to the value that is associated with the pair consisting of f1 and f2. More...
 
T2 & operator[] (const Pair &pair)
 return a reference to the value that is associated with the pair More...
 
T2 & operator() (T1 f1, T1 f2)
 return a reference to the value that is associated with the pair consisting of f1 and f2. More...
 
void erase (const Pair &pair)
 Erase a pair from the map. More...
 
void erase (T1 f1, T1 f2)
 Erase a pair from the map. More...
 
void clear ()
 Clear the map.
 
std::size_t size () const
 Return the map size. More...
 
std::size_t max_size () const
 Return maximum size. More...
 
bool empty () const
 Test whether map is empty. More...
 

Detailed Description

template<class T1, class T2>
class rw::common::PairMap< T1, T2 >

a specialized mapping implementation for pairs. It uses the internal structure of template T1 to provide fast O(1) lookup for mappings from a Pair to anything. The order of the Pairs does not matter.

Note
A requirement is that all pairs must be registered in the same StateStructure.

Constructor & Destructor Documentation

◆ PairMap()

PairMap ( const T2 &  defaultVal)
inline

creates a map with an initial size of s

Parameters
defaultVal[in] the default value of new instances of T

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Test whether map is empty.

Returns
whether the map container is empty, i.e. whether its size is 0.

◆ erase() [1/2]

void erase ( const Pair &  pair)
inline

Erase a pair from the map.

Parameters
pair[in] the pair for which to erase from the map.

◆ erase() [2/2]

void erase ( T1  f1,
T1  f2 
)
inline

Erase a pair from the map.

Parameters
f1[in] the first frame in the pair for which to erase from the map.
f2[in] the second frame in the pair for which to erase from the map.

◆ has()

bool has ( const T1  f1,
const T1  f2 
) const
inline

True iff a value for frame has been inserted in the map (or accessed using operator[]).

Parameters
f1[in] the first in the pair for which to find its associated values.
f2[in] the second in the pair for which to find its associated values.

◆ insert()

void insert ( const Pair &  pair,
const T2 &  value 
)
inline

inserts a value into the map

Parameters
pair[in] the pair for which the value is to be associated
value[in] the value that is to be associated to the pair

◆ max_size()

std::size_t max_size ( ) const
inline

Return maximum size.

Returns
the maximum number of elements that the map object can hold.

◆ operator()() [1/2]

T2& operator() ( T1  f1,
T1  f2 
)
inline

return a reference to the value that is associated with the pair consisting of f1 and f2.

If no value has been inserted the default value of T is returned. Use has() to see if a value has been stored for frame.

Parameters
f1[in] the first frame in the pair for which to find its associated values.
f2[in] the second frame in the pair for which to find its associated values.
Returns
reference to the value associated to pair.

◆ operator()() [2/2]

const T2& operator() ( T1  f1,
T1  f2 
) const
inline

return a reference to the value that is associated with the pair consisting of f1 and f2.

If no value has been inserted the default value of T is returned. Use has() to see if a value has been stored for frame.

Parameters
f1[in] the first in the pair for which to find its associated values.
f2[in] the second in the pair for which to find its associated values.
Returns
reference to the value associated to the pair.

◆ operator[]() [1/2]

T2& operator[] ( const Pair &  pair)
inline

return a reference to the value that is associated with the pair

If no value has been inserted for pair, then the default value of T2 is inserted in the map and returned.

Parameters
pair[in] the pair for which to find its associated values.
Returns
reference to the value associated to pair.

◆ operator[]() [2/2]

const T2& operator[] ( const Pair &  pair) const
inline

return a reference to the value that is associated with the pair pair.

If no value has been inserted for pair, then the default value of T2 is returned. Use has() to see if a value has been stored for pair.

Parameters
pair[in] the pair for which to find its associated values.
Returns
reference to the value associated to the pair.

◆ size()

std::size_t size ( ) const
inline

Return the map size.

Returns
the number of elements in the map.

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