|
UtiLite
0.3.1
A lite utilities library
|
Wrappers of STL for convenient functions. More...
#include <list>#include <map>#include <set>#include <vector>#include <string>#include <algorithm>Go to the source code of this file.
Functions | |
| template<class K , class V > | |
| std::list< K > | uUniqueKeys (const std::multimap< K, V > &mm) |
| template<class K , class V > | |
| std::vector< K > | uKeys (const std::multimap< K, V > &mm) |
| template<class K , class V > | |
| std::list< K > | uKeysList (const std::multimap< K, V > &mm) |
| template<class K , class V > | |
| std::vector< V > | uValues (const std::multimap< K, V > &mm) |
| template<class K , class V > | |
| std::list< V > | uValuesList (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< K > | uKeys (const std::map< K, V > &m) |
| 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 K , class V > | |
| std::vector< V > | uValues (const std::map< K, V > &m) |
| template<class K , class V > | |
| std::list< V > | uValuesList (const std::map< K, V > &m) |
| template<class K , class V > | |
| V | uValue (const std::map< K, V > &m, const K &key, const V &defaultValue=V()) |
| template<class K , class V > | |
| V | uTake (std::map< K, V > &m, const K &key, const V &defaultValue=V()) |
| 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::vector< V >::iterator | uIteratorAt (std::vector< V > &v, const unsigned int &pos) |
| 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 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 K , class V > | |
| void | uInsert (std::map< K, V > &map, const std::pair< K, V > &pair) |
| template<class V > | |
| std::vector< V > | uListToVector (const std::list< V > &list) |
| template<class V > | |
| std::list< V > | uVectorToList (const std::vector< V > &v) |
| template<class V > | |
| void | uAppend (std::list< V > &list, const std::list< V > &newItems) |
| template<class V > | |
| int | uIndexOf (const std::vector< V > &list, const V &value) |
| std::list< std::string > | uSplit (const std::string &str, char separator= ' ') |
| bool | uIsDigit (const char c) |
| std::list< std::string > | uSplitNumChar (const std::string &str) |
| int | uStrNumCmp (const std::string &a, const std::string &b) |
Wrappers of STL for convenient functions.
All functions you will find here are here for the use of STL in a more convenient way.
| void uAppend | ( | std::list< V > & | list, |
| const std::list< V > & | newItems | ||
| ) | [inline] |
Append a list to another list.
| list | the list on which the other list will be appended |
| newItems | the list of items to be appended |
| bool uContains | ( | const std::list< V > & | list, |
| const V & | value | ||
| ) | [inline] |
Check if the list contains the specified value.
| list | the list |
| value | the value |
| bool uContains | ( | const std::map< K, V > & | map, |
| const K & | key | ||
| ) | [inline] |
Check if the map contains the specified key.
| map | the map |
| key | the key |
| bool uContains | ( | const std::multimap< K, V > & | map, |
| const K & | key | ||
| ) | [inline] |
Check if the multimap contains the specified key.
| map | the map |
| key | the key |
| 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.
| list | the list |
| value | the value |
| 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.
| bool uIsDigit | ( | const char | c | ) | [inline] |
Check if a character is a digit.
| c | the character |
| 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.
| list | the list |
| pos | the index position in the list |
| 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.
| list | the list |
| pos | the index position in the list |
| 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.
| v | the vector |
| pos | the index position in the vector |
| std::vector<K> uKeys | ( | const std::multimap< K, V > & | mm | ) | [inline] |
Get all keys from a std::multimap.
| mm | the multimap |
| std::vector<K> uKeys | ( | const std::map< K, V > & | m | ) | [inline] |
Get all keys from a std::map.
| m | the map |
| std::list<K> uKeysList | ( | const std::multimap< K, V > & | mm | ) | [inline] |
Get all keys from a std::multimap.
| mm | the multimap |
| std::list<K> uKeysList | ( | const std::map< K, V > & | m | ) | [inline] |
Get all keys from a std::map.
| m | the map |
| std::set<K> uKeysSet | ( | const std::map< K, V > & | m | ) | [inline] |
Get all keys from a std::map.
| m | the map |
| std::vector<V> uListToVector | ( | const std::list< V > & | list | ) | [inline] |
Convert a std::list to a std::vector.
| list | the list |
| std::list<std::string> uSplit | ( | const std::string & | str, |
| char | separator = ' ' |
||
| ) | [inline] |
Split a string into multiple string around the specified separator. Example:
std::list<std::string> v = split("Hello the world!", ' ');
The list v will contain {"Hello", "the", "world!"}
| str | the string |
| separator | the separator character |
| std::list<std::string> uSplitNumChar | ( | const std::string & | str | ) | [inline] |
Split a string into number and character strings. Example:
std::list<std::string> v = uSplit("Hello 03 my 65 world!");
The list v will contain {"Hello ", "03", " my ", "65", " world!"}
| str | the string |
| int uStrNumCmp | ( | const std::string & | a, |
| const std::string & | b | ||
| ) | [inline] |
Compare two alphanumeric strings. Useful to sort filenames (human-like sorting). Example:
std::string a = "Image9.jpg"; std::string b = "Image10.jpg"; int r = uStrNumCmp(a, b); // r returns -1 (a is smaller than b). In contrast, std::strcmp(a, b) would return 1.
| a | the first string |
| b | the second string |
| 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;
| m | the map |
| key | the key |
| defaultValue | the default value used if the key is not found |
| std::list<K> uUniqueKeys | ( | const std::multimap< K, V > & | mm | ) | [inline] |
Get unique keys from a std::multimap.
| mm | the multimap |
| 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.
| m | the map |
| key | the key |
| defaultValue | the default value used if the key is not found |
| 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.
| list | the list |
| pos | the index position in the list |
| 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.
| list | the list |
| pos | the index position in the list |
| std::vector<V> uValues | ( | const std::multimap< K, V > & | mm | ) | [inline] |
Get all values from a std::multimap.
| mm | the multimap |
| std::list<V> uValues | ( | const std::multimap< K, V > & | mm, |
| const K & | key | ||
| ) | [inline] |
Get values for a specified key from a std::multimap.
| mm | the multimap |
| key | the key |
| std::vector<V> uValues | ( | const std::map< K, V > & | m | ) | [inline] |
Get all values from a std::map.
| m | the map |
| std::list<V> uValuesList | ( | const std::multimap< K, V > & | mm | ) | [inline] |
Get all values from a std::multimap.
| mm | the multimap |
| std::list<V> uValuesList | ( | const std::map< K, V > & | m | ) | [inline] |
Get all values from a std::map.
| m | the map |
| std::list<V> uVectorToList | ( | const std::vector< V > & | v | ) | [inline] |
Convert a std::vector to a std::list.
| v | the vector |
1.7.6.1