boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Class template iterator_range

boost::algorithm::iterator_range — iterator_range class

Synopsis

template<typename IteratorT> 
class iterator_range {
public:
  // types
  typedef iterator_range< IteratorT > type;                   // this type 
  typedef unspecified                 value_type;             // Encapsulated value type. 
  typedef unspecified                 reference;              // Reference type. 
  typedef unspecified                 difference_type;        // Difference type. 
  typedef unspecified                 size_type;              // Size type. 
  typedef IteratorT                   const_iterator;         // const_iterator type 
  typedef IteratorT                   iterator;               // iterator type 
  typedef iterator(iterator_range::*  unspecified_bool_type;  // Safe bool conversion. 

  // construct/copy/destruct
  iterator_range();
  iterator_range(iterator, iterator);
  iterator_range(const std::pair< IteratorT, IteratorT > &);
  iterator_range(const iterator_range &);
  template<typename OtherItT> 
    iterator_range(const iterator_range< OtherItT > &);
  iterator_range& operator=(const iterator_range &);
  template<typename OtherItT> 
    iterator_range& operator=(const iterator_range< OtherItT > &);

  // public member functions
  template<typename OtherItT> 
    bool operator==(const iterator_range< OtherItT > &) const;
  template<typename OtherItT> 
    bool operator!=(const iterator_range< OtherItT > &) const;
  IteratorT begin() const;
  IteratorT end() const;
  bool empty() const;
  difference_type size() const;
  void swap(iterator_range &) ;
  operator unspecified_bool_type() const;
};

Description

An iterator_range delimits a range in a sequence by beginning and ending iterators. An iterator_range can be passed to an algorithm which requires a sequence as an input. For example, the toupper() function may most frequently be used on strings, but can also be used on iterator_ranges:

                boost::tolower( find( s, "UPPERCASE STRING" ) );

Many algorithms working with sequences take a pair of iterators, delimiting a working range, as arguments. The iterator_range class is an encapsulation of a range identified by a pair of iterators. It provides a collection interface, so it is possible to pass an instance to an algorithm requiring a collection as an input.

iterator_range construct/copy/destruct

  1. iterator_range();
  2. iterator_range(iterator Begin, iterator End);
  3. iterator_range(const std::pair< IteratorT, IteratorT > & Range);
  4. iterator_range(const iterator_range & Other);
  5. template<typename OtherItT> 
      iterator_range(const iterator_range< OtherItT > & Other);

    This constructor is provided to allow conversion between const and mutable iterator instances of this class template

  6. iterator_range& operator=(const iterator_range & Other);
  7. template<typename OtherItT> 
      iterator_range& operator=(const iterator_range< OtherItT > & Other);

iterator_range public member functions

  1. template<typename OtherItT> 
      bool operator==(const iterator_range< OtherItT > & Other) const;

    Compare operands for equality

  2. template<typename OtherItT> 
      bool operator!=(const iterator_range< OtherItT > & Other) const;

    Compare operands for non-equality

  3. IteratorT begin() const;

    Retrieve the begin iterator

  4. IteratorT end() const;

    Retrieve the end iterator

  5. bool empty() const;

    Test whether the range is empty

  6. difference_type size() const;

    Retrieve the size of the range

  7. void swap(iterator_range & Other) ;

    Swap two ranges

  8. operator unspecified_bool_type() const;
Copyright © 2002-2004 Pavol Droba

PrevUpHomeNext