At 3:01 AM +0000 3/15/02, rodrigo_braz wrote:
#include <map> #include <ostream>
#include <iostream>
#include "boost/iterator_adaptors.hpp" #include <algorithm>
using namespace std; using namespace boost;
struct pair_is_active { bool operator()(const pair<const size_t,float>& p) { return 0 < p.second; } };
ostream& operator<<(ostream& o, pair<const size_t, float> p) { return o << "(" << p.first << ", " << p.second << ")"; }
int main() { map<size_t,float> m; m[0] = 10; m[1] = 15; m[2] = 0; m[3] = 13;
copy(boost::make_filter_iterator<pair_is_active>(m.begin, m.end()),
copy(boost::make_filter_iterator<pair_is_active>(m.begin(), m.end()),
boost::make_filter_iterator<pair_is_active>(m.end(), m.end()), ostream_iterator<pair<const size_t,float> >(cout,","));
return 0; }
-- Jon Kalb Kalb@LibertySoft.com