The jsplib namespace contains general purpose classes to simplify coding - searching pairs in containers, moving container contents based on predicate and various others.
More...
Classes |
class | array_autoptr |
| a template which emulates the operation and semantics of std::auto_ptr but works with arrays only More...
|
class | CScopedTiming |
| A simple class to do scoped timing. More...
|
Functions |
template<typename InIter , typename OutIter , typename Pred > |
OutIter | copy_if (InIter begin, InIter end, OutIter outBegin, Pred p) |
| copy elements of an input iterator to an output iterator if the predicate is true
|
template<typename T , typename OutIter , typename Pred > |
void | move_if (std::list< T > &from, OutIter to, Pred p) |
| removes elements from one list and pushes to back of a container if a predicate holds true
|
template<class InIter , class searchT > |
InIter | searchFirstField (const InIter start, const InIter end, const searchT &what) |
| search first value of pairs in a container - performance is linear in container size
|
template<class InIter , class searchT > |
InIter | searchSecondField (const InIter start, const InIter end, const searchT &what) |
| search second value of pairs in a container - performance is linear in container size
|
template<typename U , typename V > |
U & | first_of (std::pair< U, V > &p) |
| returns the first part of a pair
|
template<typename U , typename V > |
V & | second_of (std::pair< U, V > &p) |
| returns the second part of a pair
|
template<typename U , typename V > |
const U & | first_of_const (const std::pair< U, V > &p) |
| returns the first part of a const pair
|
template<typename U , typename V > |
const V & | second_of_const (const std::pair< U, V > &p) |
| returns the second part of a const pair
|
The jsplib namespace contains general purpose classes to simplify coding - searching pairs in containers, moving container contents based on predicate and various others.
template<typename InIter , typename OutIter , typename Pred >
OutIter jsplib::copy_if |
( |
InIter |
begin, |
|
|
InIter |
end, |
|
|
OutIter |
outBegin, |
|
|
Pred |
p | |
|
) |
| | |
copy elements of an input iterator to an output iterator if the predicate is true
Consider using std::remove_copy_if( , , , std::not(..) ) instead
- Parameters:
-
| begin | is the start iterator of the range being tested and possibly copied |
| end | is the end iterator of the range being tested and possibly copied |
| outBegin | is the output iterator to which elements are to be copied |
| p | is the predicate which has to be true for an element to be copied |
template<typename U , typename V >
U& jsplib::first_of |
( |
std::pair< U, V > & |
p |
) |
|
returns the first part of a pair
It would then be possible to do things like: std::find_if( v.begin(), v.end(), boost::bind( std::equal_to<int>(), 1, boost::bind(first_of<int,int>,_1) ) );