[ Keywords | Classes | Data | Functions ]
Back to the top of Samples
Back to the top of Samples
template <class I1, class I2> void | Copy(I1 start, I1 end, I2 dest) ; |
template <class I, class T> I | Find(I start, I end, T value) ; |
template <class I, class T, class P> I | Find(I start, I end, T value, P fn) ; |
template <class I, class T> T | Accumulate(I start, I end, T value) ; |
template <class I, class T, class F> T | Accumulate(I start, const I end, T init, F fn) ; |
template <class I, class F> void | ForEach(I start, I end, F fn) ; |
template <class T> void | Swap(T& X, T& Y) ; |
template <class I> void | Sort(I start, I end) ; |
template <class I, class P> void | Sort(I start, I end, P fn) ; |
Back to the top of Samples
Simple algorithms, all of which can be found in the STL. The first
letter of each function, struct/class name has been capatalized to
prevent naming conflicts with the STL functions.
|
Back to the top of Samples
In template classes the following abbreviations are used.
If a template function or class requires more that one iterator, value, or function type the digits are appended. i.e.
template
Here 'start', and 'end' and of iterator type "I1" and 'dest' is of
iterator type "I2". I1 and I2 may, or may not, be the same types of
iterators.
|
Back to the top of Samples
template <class I1, class I2> void Copy(I1 start, I1 end, I2 dest) ;
#include "algorithm.h"
Copies the objects pointed to by the iterators to dest. Objects in the range [start,end) are copied.
Parameters
template <class I1, class I2> void Copy(I1 start, I1 end, I2 dest) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class T> I Find(I start, I end, T value) ;
#include "algorithm.h"
This is a simple implementation of the STL find function
Returns
Parameters
template <class I, class T> I Find(I start, I end, T value) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class T, class P> I Find(I start, I end, T value, P fn) ;
#include "algorithm.h"
A predicate version of the STL find
The parameter class P is a predicate that is expected to take to parameters of type T and return a bool.
Parameters
template <class I, class T, class P> I Find(I start, I end, T value, P fn) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class T> T Accumulate(I start, I end, T value) ;
#include "algorithm.h"
STL accumulate function
template <class I, class T> T Accumulate(I start, I end, T value) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class T, class F> T Accumulate(I start, const I end, T init, F fn) ;
#include "algorithm.h"
Clone of the STL accumulate function. Applies the function fn to each value in the range [start, end).
Parameters
template <class I, class T, class F> T Accumulate(I start, const I end, T init, F fn) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class F> void ForEach(I start, I end, F fn) ;
#include "algorithm.h"
Applies the function fn(*i) for each i in the range
template <class I, class F> void ForEach(I start, I end, F fn) ;
Function is currently defined inline.
Back to the top of Samples
template <class T> void Swap(T& X, T& Y) ;
#include "algorithm.h"
Takes two references are parameters and swaps their values
template <class T> void Swap(T& X, T& Y) ;
Function is currently defined inline.
Back to the top of Samples
template <class I> void Sort(I start, I end) ;
#include "algorithm.h"
Bubble sorts the values in the range [start, end). Sorts with operator <
template <class I> void Sort(I start, I end) ;
Function is currently defined inline.
Back to the top of Samples
template <class I, class P> void Sort(I start, I end, P fn) ;
#include "algorithm.h"
Predicate version of BubbleSort. Uses the Predicate function fn to compare values.
template <class I, class P> void Sort(I start, I end, P fn) ;
Function is currently defined inline.
Back to the top of Samples
Generated from source by the Cocoon utilities on Fri Jan 26 13:37:33 2001 .
Report problems to jkotula@vitalimages.com