STL containers extensions

// structs

template <typename STLCONTAINER>
struct mrpt::containers::ContainerReadOnlyProxyAccessor;

struct mrpt::containers::map_traits_map_as_vector;
struct mrpt::containers::map_traits_stdmap;

// classes

class mrpt::containers::MT_buffer;

// global functions

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

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

template <class T, class CONTAINER>
size_t mrpt::containers::find_in_vector(
    const T& value,
    const CONTAINER& vect
    );

template <class T>
std::list<T>::iterator mrpt::containers::erase_return_next(
    std::list<T>& cont,
    typename std::list<T>::iterator& it
    );

template <class K, class V>
std::map<K, V>::iterator mrpt::containers::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 mrpt::containers::erase_return_next(
    std::multimap<K, V>& cont,
    typename std::multimap<K, V>::iterator& it
    );

template <class T>
std::set<T>::iterator mrpt::containers::erase_return_next(
    std::set<T>& cont,
    typename std::set<T>::iterator& it
    );

template <class T>
std::string mrpt::containers::getSTLContainerAsString(const T& t);

template <class T>
void mrpt::containers::printSTLContainer(const T& t);

template <class T>
void mrpt::containers::printSTLContainerOfContainers(const T& t);

template <class T1, class T2>
std::string mrpt::containers::getMapAsString(
    const std::map<T1, T2>& m,
    const std::string& sep = " => "
    );

template <class T1, class T2>
void mrpt::containers::printMap(const std::map<T1, T2>& m);

template <class CONTAINER>
void mrpt::containers::deep_clear(CONTAINER& c);

Global Functions

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.

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.

template <class T, class CONTAINER>
size_t mrpt::containers::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.

template <class T>
std::list<T>::iterator mrpt::containers::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)

template <class K, class V>
std::map<K, V>::iterator mrpt::containers::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.

template <class K, class V>
std::multimap<K, V>::iterator mrpt::containers::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.

template <class T>
std::set<T>::iterator mrpt::containers::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.

template <class T>
std::string mrpt::containers::getSTLContainerAsString(const T& t)

Return a STL container in std::string form.

Parameters:

t

Template STL container (e.g. vector)

Returns:

String form of given STL container

template <class T>
void mrpt::containers::printSTLContainer(const T& t)

Print the given vector t.

Parameters:

t

Template vector

template <class T>
void mrpt::containers::printSTLContainerOfContainers(const T& t)

Print the given STL container of containers t.

Parameters:

t

Template STL container (containing other containers)

template <class T1, class T2>
std::string mrpt::containers::getMapAsString(
    const std::map<T1, T2>& m,
    const std::string& sep = " => "
    )

Return contents of map in a string representation.

Parameters:

m

Template map

sep

String that seperates visually each key and its value. Defaults to ” => “

Returns:

std::string representation of map

template <class T1, class T2>
void mrpt::containers::printMap(const std::map<T1, T2>& m)

Print the given map m.

Parameters:

m

Template map

template <class CONTAINER>
void mrpt::containers::deep_clear(CONTAINER& c)

Deep clear for a std vector container.