DUtils::STL Class Reference
Functions to use with STL containers.
More...
#include <STL.h>
List of all members.
Classes |
struct | index_cmp |
Static Public Member Functions |
template<class T > |
static void | removeIndices (std::vector< T > &data, const std::vector< unsigned int > &indices, bool preserve_order=true) |
template<class T > |
static void | removeIndices (std::vector< T > &data, std::vector< unsigned int > &indices, bool preserve_order=true) |
template<class T > |
static void | removeIndices (std::vector< T > &data, const std::vector< unsigned char > &status, bool preserve_order=true) |
template<class T > |
static void | print (const std::vector< T > &v, const std::string &name, std::ostream &f=std::cout) |
template<class RandomIt > |
static void | indexSort (RandomIt first, RandomIt last, std::vector< unsigned int > &sorted_indexes) |
template<class RandomIt , class Compare > |
static void | indexSort (RandomIt first, RandomIt last, std::vector< unsigned int > &sorted_indexes, Compare fun) |
template<class RandomIt > |
static void | arrange (RandomIt first, RandomIt last, const std::vector< unsigned int > &indices) |
template<class T > |
static void | _removeIndices (std::vector< T > &data, const std::vector< unsigned int > &indices, bool preserve_order) |
Detailed Description
Functions to use with STL containers.
Member Function Documentation
template<class T >
void DUtils::STL::_removeIndices |
( |
std::vector< T > & |
data, |
|
|
const std::vector< unsigned int > & |
indices, |
|
|
bool |
preserve_order | |
|
) |
| | [inline, static] |
Removes the items of given indices from data
- Parameters:
-
| data | (in/out) vector to remove items from |
| indices | indices of items to remove. It must be in ascending order, with valid and no repeated indexes. If they are not, use the removeIndices functions instead. |
| preserve_order | if true, the items kept in data are in the same order as given. If false, the order may be different; this makes this operation faster |
template<class RandomIt >
void DUtils::STL::arrange |
( |
RandomIt |
first, |
|
|
RandomIt |
last, |
|
|
const std::vector< unsigned int > & |
indices | |
|
) |
| | [inline, static] |
Arranges items of a container in the given order. This function is useful after an indexSort
- Parameters:
-
| first | first element of ranged data: [first, last) |
| last | last+1 element of ranged data: [first, last) |
| indices | indexes of the items in their final place indices must have length == last-first, with no repeated and valid items |
template<class RandomIt , class Compare >
void DUtils::STL::indexSort |
( |
RandomIt |
first, |
|
|
RandomIt |
last, |
|
|
std::vector< unsigned int > & |
sorted_indexes, |
|
|
Compare |
fun | |
|
) |
| | [inline, static] |
Returns the indexes of the sorted input elements in the range [first, last), without moving the input data
- Parameters:
-
| first | |
| last | |
| sorted_indexes | (out) indexes in the order |
| fun | comparison function |
template<class RandomIt >
void DUtils::STL::indexSort |
( |
RandomIt |
first, |
|
|
RandomIt |
last, |
|
|
std::vector< unsigned int > & |
sorted_indexes | |
|
) |
| | [inline, static] |
Returns the indexes of the sorted input elements in the range [first, last), without moving the input data
- Parameters:
-
| first | |
| last | |
| sorted_indexes | (out) indexes in the order |
template<class T >
void DUtils::STL::print |
( |
const std::vector< T > & |
v, |
|
|
const std::string & |
name, |
|
|
std::ostream & |
f = std::cout | |
|
) |
| | [inline, static] |
Prints the content of the vector in f Format: <name> = [ v1 v2 ... ]
- Parameters:
-
| v | |
| name | (optional) name given to the printed variable |
| f | stream |
template<class T >
void DUtils::STL::removeIndices |
( |
std::vector< T > & |
data, |
|
|
const std::vector< unsigned char > & |
status, |
|
|
bool |
preserve_order = true | |
|
) |
| | [inline, static] |
Removes from data the items whose status is 0
- Parameters:
-
| data | (in/out) vector to remove items from |
| status | status of items in the vector.Those with status 0 are removed |
| preserve_order | if true, the items kept in data are in the same order as given. If false, the order may be different; this makes this operation faster |
template<class T >
void DUtils::STL::removeIndices |
( |
std::vector< T > & |
data, |
|
|
std::vector< unsigned int > & |
indices, |
|
|
bool |
preserve_order = true | |
|
) |
| | [inline, static] |
Removes from data the items of given indices, but can modify the index vector
- Parameters:
-
| data | (in/out) vector to remove items from |
| indices | indices of items to remove |
| preserve_order | if true, the items kept in data are in the same order as given. If false, the order may be different; this makes this operation faster |
template<class T >
void DUtils::STL::removeIndices |
( |
std::vector< T > & |
data, |
|
|
const std::vector< unsigned int > & |
indices, |
|
|
bool |
preserve_order = true | |
|
) |
| | [inline, static] |
Removes from data the items of given indices
- Parameters:
-
| data | (in/out) vector to remove items from |
| indices | indices of items to remove |
| preserve_order | if true, the items kept in data are in the same order as given. If false, the order may be different; this makes this operation faster |
The documentation for this class was generated from the following file: