Classes | Functions

jsplib Namespace Reference

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

Detailed Description

The jsplib namespace contains general purpose classes to simplify coding - searching pairs in containers, moving container contents based on predicate and various others.


Function Documentation

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) ) );

template<typename T , typename OutIter , typename Pred >
void jsplib::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

Parameters:
from is the list container that elements are to be moved from
to is the output iterator to where they are to be moved
p is the predicate which has to be true for an element to be moved
template<class InIter , class searchT >
InIter jsplib::searchFirstField ( const InIter  start,
const InIter  end,
const searchT &  what 
) [inline]

search first value of pairs in a container - performance is linear in container size

Parameters:
start is an iterator at the beginning of the range being searched
end is an iterator at one passed the end of the range being searched
what is an object that must test equal (==)
template<class InIter , class searchT >
InIter jsplib::searchSecondField ( const InIter  start,
const InIter  end,
const searchT &  what 
) [inline]

search second value of pairs in a container - performance is linear in container size

Parameters:
start is an iterator at the beginning of the range being searched
end is an iterator at one passed the end of the range being searched
what is an object that must test equal (==)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator