Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-01-23 12:21:34


Looking forward to supporting more of the adaptors from the VTL,
how about we add filter iterator to the iterator adaptors?

It looks like we need to add an initialize() function to the
policies interface in order to do this.

  template <class Predicate, class Iterator>
  class filter_iterator_policies : public default_iterator_policies {
  public:
    filter_iterator_policies() { }

    filter_iterator_policies(const Predicate& p, const Iterator& end)
      : m_predicate(p), m_end(end) { }

    void initialize(Iterator& x) {
      while (!m_predicate(*x) && x != m_end)
        ++x;
    }
    void increment(Iterator& x) {
      ++x;
      while (!m_predicate(*x) && x != m_end)
        ++x;
    }
  private:
    Predicate m_predicate;
    Iterator m_end;
  };

----------------------------------------------------------------------
 Jeremy Siek www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk