2004-07-26 00:32:12 +00:00
|
|
|
// (C) Copyright David Abrahams and Jeremy Siek 2000-2001.
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See
|
|
|
|
// accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
2000-09-18 09:49:29 +00:00
|
|
|
//
|
2001-02-04 23:37:01 +00:00
|
|
|
// Revision History:
|
|
|
|
// 04 Jan 2001 Factored counting_iterator stuff into
|
|
|
|
// boost/counting_iterator.hpp (David Abrahams)
|
2000-09-18 09:49:29 +00:00
|
|
|
|
|
|
|
#ifndef BOOST_INTEGER_RANGE_HPP_
|
|
|
|
#define BOOST_INTEGER_RANGE_HPP_
|
|
|
|
|
2000-09-27 21:02:16 +00:00
|
|
|
#include <boost/config.hpp>
|
2003-07-11 22:18:58 +00:00
|
|
|
#include <boost/iterator/counting_iterator.hpp>
|
2004-06-27 18:48:11 +00:00
|
|
|
#include <algorithm>
|
2000-09-18 09:49:29 +00:00
|
|
|
|
|
|
|
namespace boost {
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// Counting Iterator and Integer Range Class
|
|
|
|
|
|
|
|
template <class IntegerType>
|
|
|
|
struct integer_range {
|
2003-07-11 22:18:58 +00:00
|
|
|
typedef counting_iterator<IntegerType> iterator;
|
2000-09-26 07:29:12 +00:00
|
|
|
|
2000-09-18 09:49:29 +00:00
|
|
|
typedef iterator const_iterator;
|
|
|
|
typedef IntegerType value_type;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef IntegerType reference;
|
|
|
|
typedef IntegerType const_reference;
|
|
|
|
typedef const IntegerType* pointer;
|
|
|
|
typedef const IntegerType* const_pointer;
|
|
|
|
typedef IntegerType size_type;
|
|
|
|
|
|
|
|
integer_range(IntegerType start, IntegerType finish)
|
|
|
|
: m_start(start), m_finish(finish) { }
|
|
|
|
|
|
|
|
iterator begin() const { return iterator(m_start); }
|
|
|
|
iterator end() const { return iterator(m_finish); }
|
|
|
|
size_type size() const { return m_finish - m_start; }
|
|
|
|
bool empty() const { return m_finish == m_start; }
|
|
|
|
void swap(integer_range& x) {
|
|
|
|
std::swap(m_start, x.m_start);
|
|
|
|
std::swap(m_finish, x.m_finish);
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
IntegerType m_start, m_finish;
|
|
|
|
};
|
|
|
|
|
2000-10-26 14:04:50 +00:00
|
|
|
template <class IntegerType>
|
|
|
|
inline integer_range<IntegerType>
|
|
|
|
make_integer_range(IntegerType first, IntegerType last)
|
|
|
|
{
|
|
|
|
return integer_range<IntegerType>(first, last);
|
|
|
|
}
|
|
|
|
|
2000-09-18 09:49:29 +00:00
|
|
|
} // namespace boost
|
|
|
|
|
|
|
|
#endif // BOOST_INTEGER_RANGE_HPP_
|