Functions
UStl.h File Reference

Wrappers of STL for convenient functions. More...

#include <list>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <stdlib.h>
Include dependency graph for UStl.h:

Go to the source code of this file.

Functions

template<class V >
void uAppend (std::list< V > &list, const std::list< V > &newItems)
 
int uCompareVersion (const std::string &version, int major, int minor=-1, int patch=-1)
 
template<class V >
bool uContains (const std::list< V > &list, const V &value)
 
template<class K , class V >
bool uContains (const std::map< K, V > &map, const K &key)
 
template<class K , class V >
bool uContains (const std::multimap< K, V > &map, const K &key)
 
template<class V >
int uIndexOf (const std::vector< V > &list, const V &value)
 
template<class K , class V >
void uInsert (std::map< K, V > &map, const std::pair< K, V > &pair)
 
template<class K , class V >
void uInsert (std::map< K, V > &map, const std::map< K, V > &items)
 
bool uIsDigit (const char c)
 
bool uIsInteger (const std::string &str, bool checkForSign=true)
 
bool uIsNumber (const std::string &str)
 
template<class V >
std::list< V >::iterator uIteratorAt (std::list< V > &list, const unsigned int &pos)
 
template<class V >
std::list< V >::const_iterator uIteratorAt (const std::list< V > &list, const unsigned int &pos)
 
template<class V >
std::set< V >::iterator uIteratorAt (std::set< V > &set, const unsigned int &pos)
 
template<class V >
std::set< V >::const_iterator uIteratorAt (const std::set< V > &set, const unsigned int &pos)
 
template<class V >
std::vector< V >::iterator uIteratorAt (std::vector< V > &v, const unsigned int &pos)
 
template<class V >
std::vector< V >::const_iterator uIteratorAt (const std::vector< V > &v, const unsigned int &pos)
 
std::string uJoin (const std::list< std::string > &strings, const std::string &separator="")
 
template<class K , class V >
std::vector< K > uKeys (const std::multimap< K, V > &mm)
 
template<class K , class V >
std::vector< K > uKeys (const std::map< K, V > &m)
 
template<class K , class V >
std::list< K > uKeysList (const std::multimap< K, V > &mm)
 
template<class K , class V >
std::list< K > uKeysList (const std::map< K, V > &m)
 
template<class K , class V >
std::set< K > uKeysSet (const std::map< K, V > &m)
 
template<class V >
std::vector< V > uListToVector (const std::list< V > &list)
 
template<class K , class V >
std::map< K, V > uMultimapToMap (const std::multimap< K, V > &m)
 
template<class K , class V >
std::map< K, V > uMultimapToMapUnique (const std::multimap< K, V > &m)
 
std::list< std::string > uSplit (const std::string &str, char separator= ' ')
 
std::list< std::string > uSplitNumChar (const std::string &str)
 
bool uStrContains (const std::string &string, const std::string &substring)
 
int uStrNumCmp (const std::string &a, const std::string &b)
 
template<class K , class V >
uTake (std::map< K, V > &m, const K &key, const V &defaultValue=V())
 
template<class K , class V >
std::list< K > uUniqueKeys (const std::multimap< K, V > &mm)
 
template<class K , class V >
uValue (const std::map< K, V > &m, const K &key, const V &defaultValue=V())
 
template<class V >
V & uValueAt (std::list< V > &list, const unsigned int &pos)
 
template<class V >
const V & uValueAt (const std::list< V > &list, const unsigned int &pos)
 
template<class K , class V >
std::vector< V > uValues (const std::multimap< K, V > &mm)
 
template<class K , class V >
std::list< V > uValues (const std::multimap< K, V > &mm, const K &key)
 
template<class K , class V >
std::vector< V > uValues (const std::map< K, V > &m)
 
template<class K , class V >
std::list< V > uValuesList (const std::multimap< K, V > &mm)
 
template<class K , class V >
std::list< V > uValuesList (const std::map< K, V > &m)
 
template<class V >
std::list< V > uVectorToList (const std::vector< V > &v)
 

Detailed Description

Wrappers of STL for convenient functions.

All functions you will find here are here for the use of STL in a more convenient way.

Definition in file UStl.h.

Function Documentation

template<class V >
void uAppend ( std::list< V > &  list,
const std::list< V > &  newItems 
)
inline

Append a list to another list.

Parameters
listthe list on which the other list will be appended
newItemsthe list of items to be appended

Definition at line 526 of file UStl.h.

int uCompareVersion ( const std::string &  version,
int  major,
int  minor = -1,
int  patch = -1 
)
inline

Definition at line 792 of file UStl.h.

template<class V >
bool uContains ( const std::list< V > &  list,
const V &  value 
)
inline

Check if the list contains the specified value.

Parameters
listthe list
valuethe value
Returns
true if the value is found in the list, otherwise false

Definition at line 409 of file UStl.h.

template<class K , class V >
bool uContains ( const std::map< K, V > &  map,
const K &  key 
)
inline

Check if the map contains the specified key.

Parameters
mapthe map
keythe key
Returns
true if the value is found in the map, otherwise false

Definition at line 421 of file UStl.h.

template<class K , class V >
bool uContains ( const std::multimap< K, V > &  map,
const K &  key 
)
inline

Check if the multimap contains the specified key.

Parameters
mapthe map
keythe key
Returns
true if the value is found in the map, otherwise false

Definition at line 433 of file UStl.h.

template<class V >
int uIndexOf ( const std::vector< V > &  list,
const V &  value 
)
inline

Get the index in the list of the specified value. S negative index is returned if the value is not found.

Parameters
listthe list
valuethe value
Returns
the index of the value in the list

Definition at line 539 of file UStl.h.

template<class K , class V >
void uInsert ( std::map< K, V > &  map,
const std::pair< K, V > &  pair 
)
inline

Insert an item in the map. Contrary to the insert in the STL, if the key already exists, the value will be replaced by the new one.

Definition at line 443 of file UStl.h.

template<class K , class V >
void uInsert ( std::map< K, V > &  map,
const std::map< K, V > &  items 
)
inline

Insert items in the map. Contrary to the insert in the STL, if the key already exists, the value will be replaced by the new one.

Definition at line 457 of file UStl.h.

bool uIsDigit ( const char  c)
inline

Check if a character is a digit.

Parameters
cthe character
Returns
true if the character is a digit (if c >= '0' && c <= '9')

Definition at line 622 of file UStl.h.

bool uIsInteger ( const std::string &  str,
bool  checkForSign = true 
)
inline

Check if a string is a integer number.

Parameters
strthe string
Returns
true if the string is a integer number

Definition at line 632 of file UStl.h.

bool uIsNumber ( const std::string &  str)
inline

Check if a string is a number (integer or float).

Parameters
strthe string
Returns
true if the string is a number

Definition at line 647 of file UStl.h.

template<class V >
std::list<V>::iterator uIteratorAt ( std::list< V > &  list,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::list. If the position is out of range, the result is the end iterator of the list.

Parameters
listthe list
posthe index position in the list
Returns
the iterator at the specified index

Definition at line 284 of file UStl.h.

template<class V >
std::list<V>::const_iterator uIteratorAt ( const std::list< V > &  list,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::list. If the position is out of range, the result is the end iterator of the list.

Parameters
listthe list
posthe index position in the list
Returns
the iterator at the specified index

Definition at line 302 of file UStl.h.

template<class V >
std::set<V>::iterator uIteratorAt ( std::set< V > &  set,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::set. If the position is out of range, the result is the end iterator of the set.

Parameters
setthe set
posthe index position in the set
Returns
the iterator at the specified index

Definition at line 320 of file UStl.h.

template<class V >
std::set<V>::const_iterator uIteratorAt ( const std::set< V > &  set,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::set. If the position is out of range, the result is the end iterator of the set.

Parameters
setthe set
posthe index position in the set
Returns
the iterator at the specified index

Definition at line 338 of file UStl.h.

template<class V >
std::vector<V>::iterator uIteratorAt ( std::vector< V > &  v,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::vector. If the position is out of range, the result is the end iterator of the vector.

Parameters
vthe vector
posthe index position in the vector
Returns
the iterator at the specified index

Definition at line 356 of file UStl.h.

template<class V >
std::vector<V>::const_iterator uIteratorAt ( const std::vector< V > &  v,
const unsigned int &  pos 
)
inline

Get the iterator at a specified position in a std::vector. If the position is out of range, the result is the end iterator of the vector.

Parameters
vthe vector
posthe index position in the vector
Returns
the iterator at the specified index

Definition at line 369 of file UStl.h.

std::string uJoin ( const std::list< std::string > &  strings,
const std::string &  separator = "" 
)
inline

Join multiple strings into one string with optional separator. Example:

1 std::list<std::string> v;
2 v.push_back("Hello");
3 v.push_back("world!");
4  std::string joined = split(v, " ");

The output string is "Hello world!"

Parameters
stringsa list of strings
separatorthe separator string
Returns
the joined string

Definition at line 603 of file UStl.h.

template<class K , class V >
std::vector<K> uKeys ( const std::multimap< K, V > &  mm)
inline

Get all keys from a std::multimap.

Parameters
mmthe multimap
Returns
the vector which contains all keys (may contains duplicated keys)

Definition at line 67 of file UStl.h.

template<class K , class V >
std::vector<K> uKeys ( const std::map< K, V > &  m)
inline

Get all keys from a std::map.

Parameters
mthe map
Returns
the vector of keys

Definition at line 152 of file UStl.h.

template<class K , class V >
std::list<K> uKeysList ( const std::multimap< K, V > &  mm)
inline

Get all keys from a std::multimap.

Parameters
mmthe multimap
Returns
the list which contains all keys (may contains duplicated keys)

Definition at line 84 of file UStl.h.

template<class K , class V >
std::list<K> uKeysList ( const std::map< K, V > &  m)
inline

Get all keys from a std::map.

Parameters
mthe map
Returns
the list of keys

Definition at line 170 of file UStl.h.

template<class K , class V >
std::set<K> uKeysSet ( const std::map< K, V > &  m)
inline

Get all keys from a std::map.

Parameters
mthe map
Returns
the set of keys

Definition at line 186 of file UStl.h.

template<class V >
std::vector<V> uListToVector ( const std::list< V > &  list)
inline

Convert a std::list to a std::vector.

Parameters
listthe list
Returns
the vector

Definition at line 475 of file UStl.h.

template<class K , class V >
std::map<K, V> uMultimapToMap ( const std::multimap< K, V > &  m)
inline

Convert a std::multimap to a std::map

See also
uMultimapToMapUnique to keep only unique keys

Definition at line 496 of file UStl.h.

template<class K , class V >
std::map<K, V> uMultimapToMapUnique ( const std::multimap< K, V > &  m)
inline

Convert a std::multimap to a std::map, keeping only unique keys!

Definition at line 505 of file UStl.h.

std::list<std::string> uSplit ( const std::string &  str,
char  separator = ' ' 
)
inline

Split a string into multiple string around the specified separator. Example:

1 std::list<std::string> v = split("Hello the world!", ' ');

The list v will contain {"Hello", "the", "world!"}

Parameters
strthe string
separatorthe separator character
Returns
the list of strings

Definition at line 566 of file UStl.h.

std::list<std::string> uSplitNumChar ( const std::string &  str)
inline

Split a string into number and character strings. Example:

1 std::list<std::string> v = uSplit("Hello 03 my 65 world!");

The list v will contain {"Hello ", "03", " my ", "65", " world!"}

Parameters
strthe string
Returns
the list of strings

Definition at line 672 of file UStl.h.

bool uStrContains ( const std::string &  string,
const std::string &  substring 
)
inline

Check if a string contains a specified substring.

Definition at line 787 of file UStl.h.

int uStrNumCmp ( const std::string &  a,
const std::string &  b 
)
inline

Compare two alphanumeric strings. Useful to sort filenames (human-like sorting). Example:

1 std::string a = "Image9.jpg";
2 std::string b = "Image10.jpg";
3 int r = uStrNumCmp(a, b); // r returns -1 (a is smaller than b). In contrast, std::strcmp(a, b) would return 1.
Parameters
athe first string
bthe second string
Returns
-1 if a<b, 0 if a=b and 1 if a>b

Definition at line 719 of file UStl.h.

template<class K , class V >
V uTake ( std::map< K, V > &  m,
const K &  key,
const V &  defaultValue = V() 
)
inline

Get the value of a specified key from a std::map. This will remove the value from the map;

Parameters
mthe map
keythe key
defaultValuethe default value used if the key is not found
Returns
the value

Definition at line 260 of file UStl.h.

template<class K , class V >
std::list<K> uUniqueKeys ( const std::multimap< K, V > &  mm)
inline

Get unique keys from a std::multimap.

Parameters
mmthe multimap
Returns
the list which contains unique keys

Definition at line 46 of file UStl.h.

template<class K , class V >
V uValue ( const std::map< K, V > &  m,
const K &  key,
const V &  defaultValue = V() 
)
inline

Get the value of a specified key from a std::map.

Parameters
mthe map
keythe key
defaultValuethe default value used if the key is not found
Returns
the value

Definition at line 240 of file UStl.h.

template<class V >
V& uValueAt ( std::list< V > &  list,
const unsigned int &  pos 
)
inline

Get the value at a specified position in a std::list. If the position is out of range, the result is undefined.

Parameters
listthe list
posthe index position in the list
Returns
the value at the specified index

Definition at line 382 of file UStl.h.

template<class V >
const V& uValueAt ( const std::list< V > &  list,
const unsigned int &  pos 
)
inline

Get the value at a specified position in a std::list. If the position is out of range, the result is undefined.

Parameters
listthe list
posthe index position in the list
Returns
the value at the specified index

Definition at line 396 of file UStl.h.

template<class K , class V >
std::vector<V> uValues ( const std::multimap< K, V > &  mm)
inline

Get all values from a std::multimap.

Parameters
mmthe multimap
Returns
the vector which contains all values (contains values from duplicated keys)

Definition at line 100 of file UStl.h.

template<class K , class V >
std::list<V> uValues ( const std::multimap< K, V > &  mm,
const K &  key 
)
inline

Get values for a specified key from a std::multimap.

Parameters
mmthe multimap
keythe key
Returns
the list which contains the values of the key

Definition at line 134 of file UStl.h.

template<class K , class V >
std::vector<V> uValues ( const std::map< K, V > &  m)
inline

Get all values from a std::map.

Parameters
mthe map
Returns
the vector of values

Definition at line 204 of file UStl.h.

template<class K , class V >
std::list<V> uValuesList ( const std::multimap< K, V > &  mm)
inline

Get all values from a std::multimap.

Parameters
mmthe multimap
Returns
the list which contains all values (contains values from duplicated keys)

Definition at line 117 of file UStl.h.

template<class K , class V >
std::list<V> uValuesList ( const std::map< K, V > &  m)
inline

Get all values from a std::map.

Parameters
mthe map
Returns
the list of values

Definition at line 222 of file UStl.h.

template<class V >
std::list<V> uVectorToList ( const std::vector< V > &  v)
inline

Convert a std::vector to a std::list.

Parameters
vthe vector
Returns
the list

Definition at line 486 of file UStl.h.



rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:41