
Boost : 
Subject: [boost] Review Request: Creasing (Sequence Properties)
From: Grant Erickson (gerickson_at_[hidden])
Date: 20100124 14:39:40
The creasing algorithm templates define four template functions for
determining the order properties of sequences, specifically:
* Increasing
* Decreasing
* Strictly Increasing
* Strictly Decreasing
The implementation is a fairly trivial composition of the STL adjacent_find,
not2 and {greater,less,greater_equal,less_equal}.
For the purposes of sequence ordering validation, using these templates is
more efficient and straightforward than creating a temporary, sorted version
of some sequence and comparing it against the original sequence.
Example:
bool
CheckPoints(const Points & inPoints)
{
const bool strictlyIncreasing =
is_strictly_increasing(inPoints.begin(),
inPoints.end());
if (!strictlyIncreasing) {
cerr << "Points must be in increasing order with "
"no duplicate values."
<< endl;
}
return strictlyIncreasing;
}
The review files are available in both Sandbox and Vault:
Sandbox:
boost/algorithm/creasing.hpp
libs/algorithm/creasing/example/creasing_ex.cpp
libs/algorithm/creasing/example/Jamfile
libs/algorithm/creasing/test/creasing_test.cpp
libs/algorithm/creasing/test/Jamfile.v2
Vault:
http://www.boostpro.com/vault/index.php?action=downloadfile&filename=creasin
g.zip&directory=Algorithms
Regards,
Grant Erickson
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk