Boost logo

Boost Users :

From: Jon Kalb (kalb_at_[hidden])
Date: 2002-03-15 00:32:50


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_at_[hidden]

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