Main MRPT website > C++ reference for MRPT 1.9.9
Namespaces | Classes | Typedefs | Functions | Variables
mrpt::containers Namespace Reference

Namespaces

 internal
 

Classes

class  bimap
 A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std::map's, one for keys and another for values. More...
 
class  CDynamicGrid
 A 2D grid of dynamic size which stores any kind of data at each cell. More...
 
class  CDynamicGrid3D
 A 3D rectangular grid of dynamic size which stores any kind of data at each voxel. More...
 
class  circular_buffer
 A circular buffer of fixed size (defined at construction-time), implemented with a std::vector as the underlying storage. More...
 
struct  ContainerReadOnlyProxyAccessor
 A generic proxy accessor template that only allows read-only access to the original binded STL container object. More...
 
class  CThreadSafeQueue
 A thread-safe template queue for object passing between threads; for a template argument of T, the objects being passed in the queue are "T*". More...
 
class  deepcopy_poly_ptr
 Wrapper to a std::shared_ptr<>, adding deep-copy semantics to copy ctor and copy operator, suitable for polymorphic classes with a clone() method. More...
 
class  list_searchable
 This class implements a STL container with features of both, a std::set and a std::list. More...
 
class  map_as_vector
 A STL-like container which looks and behaves (almost exactly) like a std::map<> but is implemented as a linear std::vector<> indexed by KEY. More...
 
struct  map_traits_map_as_vector
 Traits for using a mrpt::utils::map_as_vector<> (dense, fastest representation) More...
 
struct  map_traits_stdmap
 Traits for using a std::map<> (sparse representation) More...
 
class  MT_buffer
 This class is a bulk sequence of bytes with MultiThread (MT)-safe read and write operations. More...
 
struct  ts_map_entry
 

Typedefs

template<typename T >
using poly_ptr = internal::generic_copier_ptr< T, internal::CopyCloner< T > >
 Smart pointer for polymorphic classes with a clone() method. More...
 
template<typename T >
using copy_ptr = internal::generic_copier_ptr< T, internal::CopyStatic< T > >
 Smart pointer for non-polymorphic classes. More...
 

Functions

template<typename src_container , typename dst_container >
void copy_container_typecasting (const src_container &src, dst_container &trg)
 Copy all the elements in a container (vector, deque, list) into a different one performing the appropriate typecasting. More...
 
template<typename T >
std::string sprintf_vector (const char *fmt, const std::vector< T > &V)
 Generates a string for a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element. More...
 
template<typename Derived >
std::string sprintf_vector (const char *fmt, const Eigen::MatrixBase< Derived > &V)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename T >
void printf_vector (const char *fmt, const std::vector< T > &V)
 Prints a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element. More...
 
template<class T , class CONTAINER >
size_t find_in_vector (const T &value, const CONTAINER &vect)
 Returns the index of the value "T" in the container "vect" (std::vector,std::deque,etc), or string::npos if not found. More...
 
template<class T >
std::list< T >::iterator erase_return_next (std::list< T > &cont, typename std::list< T >::iterator &it)
 Calls the standard "erase" method of a STL container, but also returns an iterator to the next element in the container (or end if none) More...
 
template<class K , class V >
std::map< K, V >::iterator erase_return_next (std::map< K, V > &cont, typename std::map< K, V >::iterator &it)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<class K , class V >
std::multimap< K, V >::iterator erase_return_next (std::multimap< K, V > &cont, typename std::multimap< K, V >::iterator &it)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<class T >
std::set< T >::iterator erase_return_next (std::set< T > &cont, typename std::set< T >::iterator &it)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<class T >
std::string getSTLContainerAsString (const T &t)
 Return a STL container in std::string form. More...
 
template<class T >
void printSTLContainer (const T &t)
 Print the given vector t. More...
 
template<class T >
void printSTLContainerOfContainers (const T &t)
 Print the given STL container of containers t. More...
 
template<class T1 , class T2 >
std::string getMapAsString (const std::map< T1, T2 > &m, const std::string &sep=" => ")
 Return contents of map in a string representation. More...
 
template<class T1 , class T2 >
void printMap (const std::map< T1, T2 > &m)
 Print the given map m. More...
 
void reduced_hash (const std::string &value, uint8_t &hash)
 hash function used by ts_hash_map. More...
 
void reduced_hash (const std::string &value, uint16_t &hash)
 hash function used by ts_hash_map. More...
 
void reduced_hash (const std::string &value, uint32_t &hash)
 hash function used by ts_hash_map. More...
 
void reduced_hash (const std::string &value, uint64_t &hash)
 hash function used by ts_hash_map. More...
 
template<typename KEY , typename VALUE , unsigned int NUM_BYTES_HASH_TABLE = 1, unsigned int NUM_HAS_TABLE_COLLISIONS_ALLOWED = 5, typename VECTOR_T = std::array< std::array<ts_map_entry<KEY, VALUE>, NUM_HAS_TABLE_COLLISIONS_ALLOWED>, 1u << (8 * NUM_BYTES_HASH_TABLE)>>class ts_hash_map{ public: using self_t = ts_hash_map< KEY, VALUE, NUM_BYTES_HASH_TABLE, NUM_HAS_TABLE_COLLISIONS_ALLOWED, VECTOR_T>; using key_type = KEY; using value_type = ts_map_entry<KEY, VALUE>; using vec_t = VECTOR_T; struct iterator; struct const_iterator { public: const_iterator() : m_vec(nullptr), m_parent(nullptr), m_idx_outer(0), m_idx_inner(0) { } const_iterator( const VECTOR_T& vec, const self_t& parent, int idx_outer, int idx_inner) : m_vec(const_cast<VECTOR_T*>(&vec)), m_parent(const_cast<self_t*>(&parent)), m_idx_outer(idx_outer), m_idx_inner(idx_inner) { } const_iterator& operator=(const const_iterator& o) { m_vec = o.m_vec; m_idx_outer = o.m_idx_outer; m_idx_inner = o.m_idx_inner; return *this; } bool operator==(const const_iterator& o) const { return m_vec == o.m_vec && m_idx_outer == o.m_idx_outer && m_idx_inner == o.m_idx_inner; } bool operator!=(const const_iterator& o) const { return !(*this == o); } const value_type& operator*() const { return (*m_vec)[m_idx_outer][m_idx_inner]; } const value_type* operator->() const { return &(*m_vec)[m_idx_outer][m_idx_inner]; } inline const_iterator operator++(int) { const_iterator aux = *this; ++(*this); return aux; } inline const_iterator& operator++() { incr(); return *this; } protected: VECTOR_T* m_vec; self_t* m_parent; int m_idx_outer>
iterator operator++ (int)
 A thread-safe (ts) container which minimally emulates a std::map<>'s [] and find() methods but which is implemented as a linear vector indexed by a hash of KEY. More...
 
iteratoroperator++ ()
 

Variables

vec_t m_vec
 The actual container. More...
 
size_t m_size
 Number of elements accessed with write access so far. More...
 

Function Documentation

◆ begin()

iterator mrpt::containers::begin ( ) const

Definition at line 235 of file ts_hash_map.h.

References m_vec.

◆ clear()

void mrpt::containers::clear ( )

Clear the contents of this container.

Definition at line 188 of file ts_hash_map.h.

References m_size, and m_vec.

Referenced by mrpt::math::CPolygon::Clear(), mrpt::maps::CMultiMetricMapPDF::clear(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::clearColEntries(), mrpt::maps::CMultiMetricMapPDF::CMultiMetricMapPDF(), mrpt::maps::COccupancyGridMap2D::findCriticalPoints(), IMPLEMENTS_SERIALIZABLE(), mrpt::nav::CReactiveNavigationSystem3D::implementSenseObstacles(), nanoflann::RadiusResultSet< DistanceType, IndexType >::init(), mrpt::hwdrivers::CTuMicos::init(), mrpt::maps::CPointsMap::load2Dor3D_from_text_file(), mrpt::maps::CMetricMap::loadFromProbabilisticPosesAndObservations(), mrpt::obs::CRawlog::loadFromRawLogFile(), mrpt::poses::CPoseInterpolatorBase< 3 >::loadFromTextFile(), mrpt::vision::TSequenceFeatureObservations::loadFromTextFile(), mrpt::db::CSimpleDatabase::loadFromXML(), mrpt::obs::CSensoryFrame::operator=(), mrpt::hmtslam::TArcList::read(), mrpt::poses::CPosePDFParticles::resetAroundSetOfPoses(), mrpt::nav::ClearanceDiagram::resize(), run_rnav_test(), mrpt::hmtslam::CPropertiesValuesList::serializeFrom(), mrpt::obs::CActionCollection::serializeFrom(), mrpt::opengl::CSetOfObjects::serializeFrom(), mrpt::maps::CColouredOctoMap::serializeFrom(), mrpt::hmtslam::CHierarchicalMHMap::serializeFrom(), mrpt::maps::COctoMap::serializeFrom(), mrpt::hmtslam::CMHPropertiesValuesList::serializeFrom(), mrpt::hmtslam::CRobotPosesGraph::serializeFrom(), mrpt::opengl::CAssimpModel::serializeFrom(), mrpt::maps::CBeaconMap::serializeFrom(), mrpt::obs::CSensoryFrame::serializeFrom(), mrpt::obs::CRawlog::serializeFrom(), mrpt::obs::CObservationGPS::serializeFrom(), mrpt::hmtslam::THypothesisIDSet::serializeFrom(), mrpt::db::CSimpleDatabase::serializeFrom(), nanoflann::RadiusResultSet< DistanceType, IndexType >::set_radius_and_clear(), mrpt::graphslam::TUncertaintyPath< GRAPH_T >::TUncertaintyPath(), mrpt::hmtslam::CHierarchicalMHMap::~CHierarchicalMHMap(), mrpt::hmtslam::CMHPropertiesValuesList::~CMHPropertiesValuesList(), mrpt::hmtslam::CPropertiesValuesList::~CPropertiesValuesList(), mrpt::obs::CRawlog::~CRawlog(), mrpt::opengl::CSetOfObjects::~CSetOfObjects(), and mrpt::db::CSimpleDatabase::~CSimpleDatabase().

◆ empty()

bool mrpt::containers::empty ( ) const

Definition at line 196 of file ts_hash_map.h.

References m_size.

◆ end()

iterator mrpt::containers::end ( ) const

Definition at line 241 of file ts_hash_map.h.

References m_vec.

Referenced by find().

◆ find()

const_iterator mrpt::containers::find ( const KEY &  key) const

Definition at line 219 of file ts_hash_map.h.

References end(), m_vec, and reduced_hash().

Referenced by mrpt::opengl::CPolyhedron::addEdges(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::checkPartitionsForLC(), mrpt::opengl::CSetOfObjects::contains(), mrpt::opengl::COpenGLStandardObject::enable(), mrpt::graphs::ScalarFactorGraph::eraseConstraint(), mrpt::opengl::CPolyhedron::facesInVertex(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find(), xsens::List< uint32_t >::findSorted(), mrpt::math::CBinaryRelation< T, U, UIsObject >::getRelationFrom(), mrpt::math::CBinaryRelation< T, U, UIsObject >::getRelationTo(), mrpt::math::CBinaryRelation< T, U, UIsObject >::getRelationValue(), getVerticesAndFaces(), mrpt::system::TParameters< double >::getWithDefaultVal(), mrpt::system::TParameters< double >::has(), mrpt::hmtslam::THypothesisIDSet::has(), mrpt::graphslam::CGraphSlamEngine< mrpt::graphs::CNetworkOfPoses2DInf >::initClass(), mrpt::math::CBinaryRelation< T, U, UIsObject >::insertElements(), mrpt::opengl::COpenGLStandardObject::isEnabled(), mrpt::system::TParameters< double >::operator[](), mrpt::slam::PF_implementation< mrpt::math::TPose3D, CMonteCarloLocalization3D, mrpt::bayes::particle_storage_mode::VALUE >::PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal(), mrpt::math::CBinaryRelation< T, U, UIsObject >::removeElement(), mrpt::math::CBinaryRelation< T, U, UIsObject >::removeElements(), mrpt::math::CBinaryRelation< T, U, UIsObject >::setRelationValue(), and mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::updateMapPartitionsVisualization().

◆ operator++() [1/2]

iterator& mrpt::containers::operator++ ( )
inline

Definition at line 169 of file ts_hash_map.h.

◆ operator++() [2/2]

template<typename KEY , typename VALUE , unsigned int NUM_BYTES_HASH_TABLE = 1, unsigned int NUM_HAS_TABLE_COLLISIONS_ALLOWED = 5, typename VECTOR_T = std::array< std::array<ts_map_entry<KEY, VALUE>, NUM_HAS_TABLE_COLLISIONS_ALLOWED>, 1u << (8 * NUM_BYTES_HASH_TABLE)>>class ts_hash_map{ public: using self_t = ts_hash_map< KEY, VALUE, NUM_BYTES_HASH_TABLE, NUM_HAS_TABLE_COLLISIONS_ALLOWED, VECTOR_T>; using key_type = KEY; using value_type = ts_map_entry<KEY, VALUE>; using vec_t = VECTOR_T; struct iterator; struct const_iterator { public: const_iterator() : m_vec(nullptr), m_parent(nullptr), m_idx_outer(0), m_idx_inner(0) { } const_iterator( const VECTOR_T& vec, const self_t& parent, int idx_outer, int idx_inner) : m_vec(const_cast<VECTOR_T*>(&vec)), m_parent(const_cast<self_t*>(&parent)), m_idx_outer(idx_outer), m_idx_inner(idx_inner) { } const_iterator& operator=(const const_iterator& o) { m_vec = o.m_vec; m_idx_outer = o.m_idx_outer; m_idx_inner = o.m_idx_inner; return *this; } bool operator==(const const_iterator& o) const { return m_vec == o.m_vec && m_idx_outer == o.m_idx_outer && m_idx_inner == o.m_idx_inner; } bool operator!=(const const_iterator& o) const { return !(*this == o); } const value_type& operator*() const { return (*m_vec)[m_idx_outer][m_idx_inner]; } const value_type* operator->() const { return &(*m_vec)[m_idx_outer][m_idx_inner]; } inline const_iterator operator++(int) { const_iterator aux = *this; ++(*this); return aux; } inline const_iterator& operator++() { incr(); return *this; } protected: VECTOR_T* m_vec; self_t* m_parent; int m_idx_outer>
iterator mrpt::containers::operator++ ( int  )
inline

A thread-safe (ts) container which minimally emulates a std::map<>'s [] and find() methods but which is implemented as a linear vector indexed by a hash of KEY.

Any custom hash function can be implemented, we don't rely by default on C++11 std::hash<> due to its limitation in some implementations.

This implementation is much more efficient than std::map<> when the most common operation is accesing elements by KEY with find() or [], and is also thread-safe if different threads create entries with different hash values.

The default underlying non-associative container is a "memory-aligned std::vector<>", but it can be changed to a standard vector<> or to a deque<> (to avoid memory reallocations) by changing the template parameter VECTOR_T.

Note
Defined in #include <mrpt/containers/ts_hash_map.h>

Definition at line 163 of file ts_hash_map.h.

◆ operator[]()

VALUE& mrpt::containers::operator[] ( const KEY &  key)

◆ printf_vector()

template<typename T >
void mrpt::containers::printf_vector ( const char *  fmt,
const std::vector< T > &  V 
)

Prints a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element.

Definition at line 56 of file printf_vector.h.

References sprintf_vector().

Referenced by mrpt::hmtslam::CHMTSLAM::TMessageLSLAMfromAA::dumpToConsole().

◆ reduced_hash() [1/4]

void mrpt::containers::reduced_hash ( const std::string value,
uint16_t hash 
)

hash function used by ts_hash_map.

Uses dbj2 method

Definition at line 35 of file ts_hash_map.cpp.

References MAKEWORD16B, reduced_hash(), SELBYTE0, SELBYTE1, SELBYTE2, and SELBYTE3.

◆ reduced_hash() [2/4]

void mrpt::containers::reduced_hash ( const std::string value,
uint32_t hash 
)

hash function used by ts_hash_map.

Uses dbj2 method

Definition at line 44 of file ts_hash_map.cpp.

References reduced_hash().

◆ reduced_hash() [3/4]

void mrpt::containers::reduced_hash ( const std::string value,
uint64_t hash 
)

hash function used by ts_hash_map.

Uses dbj2 method

Definition at line 17 of file ts_hash_map.cpp.

◆ reduced_hash() [4/4]

void mrpt::containers::reduced_hash ( const std::string value,
uint8_t hash 
)

hash function used by ts_hash_map.

Uses dbj2 method

Definition at line 28 of file ts_hash_map.cpp.

References SELBYTE0, SELBYTE1, SELBYTE2, and SELBYTE3.

Referenced by find(), operator[](), reduced_hash(), and simple_test_hash_string().

◆ sprintf_vector() [1/2]

template<typename Derived >
std::string mrpt::containers::sprintf_vector ( const char *  fmt,
const Eigen::MatrixBase< Derived > &  V 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 40 of file printf_vector.h.

References mrpt::format().

◆ sprintf_vector() [2/2]

template<typename T >
std::string mrpt::containers::sprintf_vector ( const char *  fmt,
const std::vector< T > &  V 
)

Generates a string for a vector in the format [A,B,C,...] to std::cout, and the fmt string for each vector element.

Definition at line 26 of file printf_vector.h.

References mrpt::format().

Referenced by mrpt::math::CLevenbergMarquardtTempl< VECTORTYPE, USERPARAM >::execute(), mrpt::nav::CAbstractPTGBasedReactive::TNavigationParamsPTG::getAsText(), and printf_vector().

◆ ts_hash_map()

mrpt::containers::ts_hash_map ( )

< Default constructor *‍/

Definition at line 186 of file ts_hash_map.h.

Variable Documentation

◆ m_size

size_t mrpt::containers::m_size
private

◆ m_vec

vec_t mrpt::containers::m_vec
private

The actual container.

Definition at line 174 of file ts_hash_map.h.

Referenced by begin(), clear(), end(), find(), and operator[]().




Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST