MRPT  1.9.9
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...
 
struct  ci_less
 A case-insensitive comparator class for use within STL containers, etc. 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::containers::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
 
struct  UnspecializedBool
 
class  vector_with_small_size_optimization
 Container that transparently and dynamically switches between a std::array and std::vector. More...
 

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 VEC >
std::string sprintf_vector (const char *fmt, const VEC &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 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)
 
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)
 
template<class T >
std::set< T >::iterator erase_return_next (std::set< T > &cont, typename std::set< T >::iterator &it)
 
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...
 
template<class CONTAINER >
void deep_clear (CONTAINER &c)
 Deep clear for a std vector container. More...
 
void reduced_hash (const std::string_view &value, uint8_t &hash)
 hash function used by ts_hash_map. More...
 
void reduced_hash (const std::string_view &value, uint16_t &hash)
 
void reduced_hash (const std::string_view &value, uint32_t &hash)
 
void reduced_hash (const std::string_view &value, uint64_t &hash)
 
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) {} 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{0}>
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...
 
iterator & operator++ ()
 
Constructors, read/write access and other operations
 ts_hash_map ()=default
 < Default constructor */ More...
 
void clear ()
 Clear the contents of this container. More...
 
bool empty () const
 
VALUE & operator[] (const KEY &key)
 Write/read via [i] operator, that creates an element if it didn't exist already. More...
 
const_iterator find (const KEY &key) const
 
const_iterator begin () const
 
const_iterator end () const
 

Variables

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

Function Documentation

◆ begin()

iterator mrpt::containers::begin ( ) const

Definition at line 229 of file ts_hash_map.h.

References m_vec.

Referenced by mrpt::opengl::CPolyhedron::cantellate(), mrpt::vision::TSequenceFeatureObservations::compressIDs(), mrpt::vision::CFeatureList::copyListFrom(), mrpt::vision::TSequenceFeatureObservations::decimateCameraFrames(), mrpt::obs::CSensoryFrame::eraseByIndex(), mrpt::obs::CSensoryFrame::eraseByLabel(), mrpt::vision::CFeatureLines::extractLines(), mrpt::math::MatrixVectorBase< T, CMatrixFixed< T, ROWS, COLS > >::fill(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find_ptr_to(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::findCurrentNumberOfRows(), mrpt::vision::findMultipleChessboardsCorners(), generate_test_data(), mrpt::vision::CMatchedFeatureList::get_type(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getAsDense(), mrpt::math::MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP, INDEX_REMAP_MAP_IMPL >::getBinaryBlocksRepresentation(), mrpt::vision::CMatchedFeatureList::getBothFeatureLists(), mrpt::vision::CFeatureList::getByID(), mrpt::vision::CMatchedFeatureList::getByID(), mrpt::math::TPolygon2D::getCenter(), mrpt::math::TPolygon3D::getCenter(), mrpt::vision::CFeatureList::getMaxID(), mrpt::opengl::CGeneralizedCylinder::getMeshIterators(), mrpt::poses::CPosePDFSOG::getMostLikelyCovarianceAndMean(), mrpt::obs::CSensoryFrame::getObservationByIndex(), mrpt::opengl::COpenGLScene::insert(), mrpt::hmtslam::CHMTSLAM::LSLAM_process_message_from_AA(), mrpt::obs::CSensoryFrame::operator+=(), nanoflann::CArray< T, N >::operator=(), mrpt::graphslam::optimize_graph_spa_levmarq(), mrpt::vision::TSequenceFeatureObservations::removeFewObservedFeatures(), nanoflann::CArray< T, N >::rend(), mrpt::opengl::CGeneralizedCylinder::render_dl(), searchForEdge(), mrpt::obs::CActionCollection::serializeFrom(), mrpt::tfest::TMatchingPairList::squareErrorVector(), nanoflann::CArray< T, N >::swap(), TEST(), and mrpt::vision::CMatchedFeatureList::updateMaxID().

Here is the caller graph for this function:

◆ clear()

void mrpt::containers::clear ( )

Clear the contents of this container.

Definition at line 182 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::CPointsMapXYZI::loadFromKittiVelodyneFile(), mrpt::maps::CMetricMap::loadFromProbabilisticPosesAndObservations(), mrpt::obs::CRawlog::loadFromRawLogFile(), mrpt::poses::CPoseInterpolatorBase< 3 >::loadFromTextFile(), mrpt::vision::TSequenceFeatureObservations::loadFromTextFile(), mrpt::db::CSimpleDatabase::loadFromXML(), mrpt::maps::CLandmarksMap::loadOccupancyFeaturesFrom2DRangeScan(), mrpt::obs::CSensoryFrame::operator=(), mrpt::hmtslam::TArcList::read(), mrpt::poses::CPosePDFParticles::resetAroundSetOfPoses(), mrpt::nav::ClearanceDiagram::resize(), run_rnav_test(), mrpt::hmtslam::CPropertiesValuesList::serializeFrom(), mrpt::opengl::CSetOfObjects::serializeFrom(), mrpt::obs::CActionCollection::serializeFrom(), mrpt::hmtslam::CHierarchicalMHMap::serializeFrom(), mrpt::hmtslam::CMHPropertiesValuesList::serializeFrom(), mrpt::hmtslam::CRobotPosesGraph::serializeFrom(), mrpt::maps::CColouredOctoMap::serializeFrom(), mrpt::opengl::CAssimpModel::serializeFrom(), mrpt::maps::COctoMap::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::config::CConfigFileBase::setContentFromYAML(), mrpt::img::CImage::setExternalStorage(), 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().

Here is the caller graph for this function:

◆ empty()

◆ end()

iterator mrpt::containers::end ( ) const

Definition at line 235 of file ts_hash_map.h.

References m_vec.

Referenced by find().

Here is the caller graph for this function:

◆ find()

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

Definition at line 213 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::hmtslam::THypothesisIDSet::has(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::initClass(), mrpt::math::CBinaryRelation< T, U, UIsObject >::insertElements(), mrpt::opengl::COpenGLStandardObject::isEnabled(), 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator++() [1/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) {} 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{0}>
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 157 of file ts_hash_map.h.

◆ operator++() [2/2]

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

Definition at line 163 of file ts_hash_map.h.

◆ operator[]()

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

Write/read via [i] operator, that creates an element if it didn't exist already.

Definition at line 193 of file ts_hash_map.h.

References m_size, m_vec, and reduced_hash().

Referenced by mrpt::math::CPolygon::getAllVertices(), mrpt::math::TPolygon2D::getPlotData(), mrpt::math::CPolygon::GetVertex_x(), mrpt::math::CPolygon::GetVertex_y(), mrpt::math::CPolygon::serializeFrom(), and mrpt::math::CPolygon::setAllVertices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 40 of file printf_vector.h.

References sprintf_vector().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reduced_hash() [1/4]

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

hash function used by ts_hash_map.

Uses dbj2 method

Definition at line 25 of file ts_hash_map.cpp.

References SELBYTE0, SELBYTE1, SELBYTE2, and SELBYTE3.

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

Here is the caller graph for this function:

◆ reduced_hash() [2/4]

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

Definition at line 33 of file ts_hash_map.cpp.

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

Here is the call graph for this function:

◆ reduced_hash() [3/4]

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

Definition at line 42 of file ts_hash_map.cpp.

References reduced_hash().

Here is the call graph for this function:

◆ reduced_hash() [4/4]

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

Definition at line 17 of file ts_hash_map.cpp.

◆ sprintf_vector()

template<typename VEC >
std::string mrpt::containers::sprintf_vector ( const char *  fmt,
const VEC &  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 24 of file printf_vector.h.

References mrpt::format().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ts_hash_map()

mrpt::containers::ts_hash_map ( )
default

< Default constructor */

Variable Documentation

◆ m_size

◆ m_vec

vec_t mrpt::containers::m_vec
private

The actual container.

Definition at line 168 of file ts_hash_map.h.

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




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ce1a28c9f Fri Aug 23 08:02:09 2019 +0200 at vie ago 23 08:10:11 CEST 2019