Classes | Functions
contrib/mul/mbl/mbl_stl.h File Reference

Useful things missing from vcl_algorithm, etc. More...

#include <vcl_functional.h>
#include <vcl_vector.h>
#include <vcl_ostream.h>

Go to the source code of this file.

Classes

struct  mbl_stl_select1st< Pair >
 select 1st element of a pair (e.g. for map iterators). More...
struct  mbl_stl_select2nd< Pair >
 select 2nd element of a pair (e.g. for map iterators). More...
struct  mbl_stl_add2nd< Pair >
class  mbl_stl_index_functor< T >
 Given a vector of things, select an indexed element. More...
class  mbl_stl_output_t1< Cont >
 implementation class for use with mbl_stl_output. More...

Functions

template<class Out , class T >
mbl_stl_increments (Out first, Out last, T init)
 Fill an output sequence with incrementing values.
template<class Out , class Size , class T >
mbl_stl_increments_n (Out first, Size n, T init)
 Fill the first n values of an output sequence with incrementing values.
template<class Out , class T , class UnOp >
mbl_stl_sequence (Out first, Out last, UnOp op, T init)
 Produces a first order sequence from the supplied unary function.
template<class Out , class Size , class T , class UnOp >
mbl_stl_sequence_n (Out first, Size n, UnOp op, T init)
 Produces a first order sequence of size n from the supplied function.
template<class iterType >
void mbl_stl_clean (iterType first, iterType last)
 Clean out a range of pointers.
template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator mbl_stl_copy_if (InputIterator begin, InputIterator end, OutputIterator destBegin, Predicate pred)
 Copy elements in input range for which the supplied predicate is true.
template<class Cont >
vcl_ostream & operator<< (vcl_ostream &s, const mbl_stl_output_t1< Cont > &t)
 implementation function for use with mbl_stl_output.
template<class Cont >
mbl_stl_output_t1< Cont > mbl_stl_output (const Cont &c, const char *sep=" ")
 Allow easy stream output of STL container contents.

Detailed Description

Useful things missing from vcl_algorithm, etc.

Author:
iscott
Date:
Dec 2001 Actually, this is mostly an opportunity to mess around in STL to produce code which would be much simpler in ordinary C++. Stroustrup assures us that this approach is faster in general - which I don't really believe.

Added quite a few little functors mainly to do with iterating through maps for example a version of the non-standard select1st and select2nd 30 April 2004 Martin Roberts

Definition in file mbl_stl.h.


Function Documentation

template<class iterType >
void mbl_stl_clean ( iterType  first,
iterType  last 
) [inline]

Clean out a range of pointers.

NB the dereferenced iterator must be a pointer

Definition at line 72 of file mbl_stl.h.

template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator mbl_stl_copy_if ( InputIterator  begin,
InputIterator  end,
OutputIterator  destBegin,
Predicate  pred 
) [inline]

Copy elements in input range for which the supplied predicate is true.

Note bizarely although the STL provides remove_copy if etc etc the simple copy_if was dropped fromn the C++ standard

Definition at line 87 of file mbl_stl.h.

template<class Out , class T >
T mbl_stl_increments ( Out  first,
Out  last,
init 
) [inline]

Fill an output sequence with incrementing values.

A bit like vcl_fill, but after each assignment, the value is incremented.

Returns:
the next value in the sequence.

Definition at line 27 of file mbl_stl.h.

template<class Out , class Size , class T >
T mbl_stl_increments_n ( Out  first,
Size  n,
init 
) [inline]

Fill the first n values of an output sequence with incrementing values.

A bit like vcl_fill_n, but after each assignment, the value is incremented.

Returns:
the next value in the sequence.

Definition at line 38 of file mbl_stl.h.

template<class Cont >
mbl_stl_output_t1<Cont> mbl_stl_output ( const Cont &  c,
const char *  sep = " " 
) [inline]

Allow easy stream output of STL container contents.

   vcl_vector<int> c;
   ...
   vcl_cout << "The contents of c using normal << notation" <<
     mbl_stl_output(c) << vcl_endl;
   

Definition at line 200 of file mbl_stl.h.

template<class Out , class T , class UnOp >
T mbl_stl_sequence ( Out  first,
Out  last,
UnOp  op,
init 
) [inline]

Produces a first order sequence from the supplied unary function.

The value produced at a given step is a function of the previous value. E.g. the following is equivalent to using mbl_stl_increments

 mbl_stl_sequence(A.begin(), A.end(), vcl_bind1st(vcl_plus<unsigned>(), 1u), 0u);
Returns:
the next value in the sequence.

Definition at line 52 of file mbl_stl.h.

template<class Out , class Size , class T , class UnOp >
T mbl_stl_sequence_n ( Out  first,
Size  n,
UnOp  op,
init 
) [inline]

Produces a first order sequence of size n from the supplied function.

The value produced at a given step is a function of the previous value. E.g. the following is equivalent to using mbl_stl_increments

Returns:
the next value in the sequence.

Definition at line 63 of file mbl_stl.h.

template<class Cont >
vcl_ostream& operator<< ( vcl_ostream &  s,
const mbl_stl_output_t1< Cont > &  t 
) [inline]

implementation function for use with mbl_stl_output.

Definition at line 181 of file mbl_stl.h.