MRPT
2.0.4
|
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 |
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(const const_iterator& o) { *this = o; } 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 * | find_or_alloc (const KEY &key) noexcept |
noexcept version of operator[], returns nullptr upon failure More... | |
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... | |
iterator mrpt::containers::begin | ( | ) | const |
Definition at line 240 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::poses::CPosePDFSOG::getMostLikelyCovarianceAndMean(), mrpt::obs::CSensoryFrame::getObservationByIndex(), mrpt::opengl::COpenGLScene::insert(), mrpt::hmtslam::CHMTSLAM::LSLAM_process_message_from_AA(), nanoflann::CArray< T, N >::operator=(), mrpt::graphslam::optimize_graph_spa_levmarq(), mrpt::vision::TSequenceFeatureObservations::removeFewObservedFeatures(), nanoflann::CArray< T, N >::rend(), searchForEdge(), mrpt::obs::CActionCollection::serializeFrom(), mrpt::tfest::TMatchingPairList::squareErrorVector(), nanoflann::CArray< T, N >::swap(), TEST(), and mrpt::vision::CMatchedFeatureList::updateMaxID().
void mrpt::containers::clear | ( | ) |
Clear the contents of this container.
Definition at line 183 of file ts_hash_map.h.
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::opengl::Shader::compile(), mrpt::maps::COccupancyGridMap2D::findCriticalPoints(), IMPLEMENTS_SERIALIZABLE(), mrpt::nav::CReactiveNavigationSystem3D::implementSenseObstacles(), nanoflann::RadiusResultSet< DistanceType, IndexType >::init(), mrpt::hwdrivers::CTuMicos::init(), mrpt::opengl::Program::linkProgram(), mrpt::maps::CPointsMap::load2Dor3D_from_text_file(), mrpt::maps::CPointsMap::load2Dor3D_from_text_stream(), mrpt::maps::CPointsMapXYZI::loadFromKittiVelodyneFile(), mrpt::maps::CMetricMap::loadFromProbabilisticPosesAndObservations(), mrpt::obs::CRawlog::loadFromRawLogFile(), mrpt::poses::CPoseInterpolatorBase< 3 >::loadFromTextFile(), mrpt::vision::TSequenceFeatureObservations::loadFromTextFile(), mrpt::maps::CLandmarksMap::loadOccupancyFeaturesFrom2DRangeScan(), mrpt::maps::CPointsMapXYZI::loadXYZI_from_text_file(), 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::maps::COctoMap::serializeFrom(), mrpt::maps::CBeaconMap::serializeFrom(), mrpt::opengl::CAssimpModel::serializeFrom(), mrpt::obs::CSensoryFrame::serializeFrom(), mrpt::obs::CRawlog::serializeFrom(), mrpt::obs::CObservationGPS::serializeFrom(), mrpt::hmtslam::THypothesisIDSet::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::opengl::Program::~Program(), and mrpt::opengl::Shader::~Shader().
bool mrpt::containers::empty | ( | ) | const |
Definition at line 191 of file ts_hash_map.h.
References m_size.
Referenced by mrpt::opengl::Program::declareAttribute(), mrpt::opengl::Program::declareUniform(), deep_clear(), mrpt::opengl::Program::dumpProgramDescription(), mrpt::vision::CMatchedFeatureList::get_type(), mrpt::math::TPolygon2D::getBoundingBox(), mrpt::vision::CFeatureList::getMaxID(), mrpt::vision::CMatchedFeatureList::getMaxID(), mrpt::poses::CPose3DPDFSOG::getMostLikelyMode(), mrpt::poses::CPointPDFSOG::getMostLikelyMode(), mrpt::config::simpleini::CSimpleIniTempl< SI_CHAR, SI_STRLESS, SI_CONVERTER >::Load(), mrpt::nav::CHolonomicFullEval::TOptions::loadFromConfigFile(), mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_ext_params_from_yml(), mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_int_params_from_yml(), mrpt::vision::CFeatureList::nearest(), mrpt::slam::CMetricMapBuilderICP::processObservation(), and mrpt::opengl::CAssimpModel::serializeTo().
iterator mrpt::containers::end | ( | ) | const |
Definition at line 246 of file ts_hash_map.h.
References m_vec.
Referenced by mrpt::opengl::CPolyhedron::cantellate(), mrpt::maps::COctoMapBase< octomap::OcTree, octomap::OcTreeNode >::castRay(), mrpt::detectors::CFaceDetection::checkIfFaceRegions(), mrpt::vision::TSequenceFeatureObservations::compressIDs(), mrpt::vision::TSequenceFeatureObservations::decimateCameraFrames(), mrpt::apps::MonteCarloLocalization_Base::do_pf_localization(), mrpt::obs::CActionCollection::erase(), mrpt::obs::CSensoryFrame::erase(), mrpt::obs::CSensoryFrame::eraseByLabel(), mrpt::nav::CHolonomicND::evaluateGaps(), mrpt::graphs::CGraphPartitioner< GRAPH_MATRIX, num_t >::exactBisection(), mrpt::vision::CFeatureLines::extractLines(), mrpt::io::file_get_contents(), mrpt::math::MatrixVectorBase< T, CMatrixFixed< T, ROWS, COLS > >::fill(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find(), find(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find_ptr_to(), mrpt::math::MatrixVectorBase< T, CMatrixFixed< T, ROWS, COLS > >::fromMatlabStringFormat(), mrpt::nav::CHolonomicND::gapsEstimator(), generate_test_data(), mrpt::vision::CMatchedFeatureList::getBothFeatureLists(), mrpt::vision::CFeatureList::getByID(), mrpt::vision::CMatchedFeatureList::getByID(), mrpt::math::TPolygon2D::getCenter(), mrpt::math::TPolygon3D::getCenter(), mrpt::poses::CPosePDFSOG::getMostLikelyCovarianceAndMean(), mrpt::io::CFileInputStream::getTotalBytesCount(), mrpt::io::CFileOutputStream::getTotalBytesCount(), mrpt::io::CFileStream::getTotalBytesCount(), mrpt::hmtslam::THypothesisIDSet::has(), mrpt::opengl::COpenGLScene::insert(), mrpt::maps::COccupancyGridMap3D::insertRay(), mrpt::hwdrivers::C2DRangeFinderAbstract::loadCommonParams(), mrpt::img::CImage::loadFromXPM(), mrpt::img::CImage::loadTGA(), nanoflann::CArray< T, N >::rbegin(), run_test_pf_localization(), searchForEdge(), mrpt::io::CFileInputStream::Seek(), mrpt::io::CFileOutputStream::Seek(), mrpt::io::CFileStream::Seek(), mrpt::obs::CActionCollection::serializeFrom(), mrpt::tfest::TMatchingPairList::squareErrorVector(), nanoflann::CArray< T, N >::swap(), TEST(), mrpt::vision::CMatchedFeatureList::updateMaxID(), and mrpt::comms::CSerialPort::Write().
const_iterator mrpt::containers::find | ( | const KEY & | key | ) | const |
Definition at line 224 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::graphs::ScalarFactorGraph::eraseConstraint(), mrpt::opengl::CPolyhedron::facesInVertex(), mrpt::containers::list_searchable< CHMHMapNode::TNodeID >::find(), 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::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().
|
noexcept |
noexcept version of operator[], returns nullptr upon failure
Definition at line 193 of file ts_hash_map.h.
References m_size, m_vec, and reduced_hash().
Referenced by operator[]().
|
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.
Definition at line 158 of file ts_hash_map.h.
|
inline |
Definition at line 164 of file ts_hash_map.h.
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 216 of file ts_hash_map.h.
References find_or_alloc().
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().
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().
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(), find_or_alloc(), reduced_hash(), and simple_test_hash_string().
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.
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().
void mrpt::containers::reduced_hash | ( | const std::string_view & | value, |
uint64_t & | hash | ||
) |
Definition at line 17 of file ts_hash_map.cpp.
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().
|
default |
< Default constructor */
|
private |
Number of elements accessed with write access so far.
Definition at line 175 of file ts_hash_map.h.
Referenced by nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::buildIndex(), clear(), empty(), find_or_alloc(), nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::init_vind(), nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::KDTreeSingleIndexAdaptor(), nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::loadIndex(), nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::saveIndex(), and nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::size().
|
private |
The actual container.
Definition at line 169 of file ts_hash_map.h.
Referenced by begin(), clear(), end(), find(), and find_or_alloc().
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |