Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2002-02-10 10:31:03


Jonathan -

This sounds like it would make a nice extension to the STLAlogorithmExtension
library that Jeremy Siek has suggested and all sorts of boosters have
recommended algorithms for. Check out the Wiki page and add it in.

http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?STLAlgorithmExten
sions

Jeff

> -----Original Message-----
> From: Jonathan Brownell [mailto:alphaomega_at_[hidden]]
> Sent: Saturday, February 09, 2002 11:47 PM
> To: Boost-Users_at_[hidden]
> Subject: [Boost-Users] Possible interest in select_by_predicate?
>
>
> I work in doing programming involving quite a bit of data analysis, and
> lately I've gotten sick and tired of doing routine searches on vectors
> and other linear containers to pull out maximum/minimum values. I ended
> up sitting down and writing a unary function object that retains a value
> based on any predicate. An example is worth a thousand words:
>
> int array[10] = { 5, 4, 6, 3, 9, 0, 7, 2, 8, 1 };
>
> int maximum = std::for_each(&array[0], &array[10],
> select_by_predicate<int, std::greater>());
>
> int minimum = std::for_each(&array[0], &array[10],
> select_by_predicate<int, std::less>());
>
> assert(maximum == 9 && minimum == 0);
>
>
> Another example, using select_by_predicate independently:
>
> select_by_predicate<int, std::greater> max_error(0);
>
> for(loop through data samples)
> {
> double error;
> ... analyze data sample error ...
>
> max_error.compare(error); // same as max_error(error)
> }
>
> std::cout << "Maximum error: " << max_error;
>
>
> Is select_by_predicate something that boost users would be interested
> in? It's been helpful to me in all kinds of contexts.
>
> -Jonathan
>
>
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net