mirror of
https://github.com/boostorg/python.git
synced 2026-01-28 07:22:31 +00:00
Renamed iterator_pair to iterator_range
[SVN r20508]
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
// -*- mode:c++ -*-
|
||||
//
|
||||
// Header file algo_selector.hpp
|
||||
//
|
||||
// Automatic selection of container algorithms (and traits) for known
|
||||
// container types (basically, all STL container instances, as well as
|
||||
// iterator_pair instances).
|
||||
// iterator_range instances).
|
||||
//
|
||||
// Copyright (c) 2003 Raoul M. Gough
|
||||
//
|
||||
@@ -31,7 +29,7 @@
|
||||
#include <boost/python/suite/indexing/algorithms.hpp>
|
||||
|
||||
// Definitions of further supported types
|
||||
#include <boost/python/suite/indexing/iterator_pair.hpp>
|
||||
#include <boost/python/suite/indexing/iterator_range.hpp>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <list>
|
||||
@@ -152,12 +150,12 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
// Iterator ranges
|
||||
template <typename Iterator>
|
||||
class selector_impl<iterator_pair<Iterator> >
|
||||
class selector_impl<iterator_range<Iterator> >
|
||||
{
|
||||
typedef iterator_pair<Iterator> Container;
|
||||
typedef iterator_range<Iterator> Container;
|
||||
|
||||
typedef iterator_pair_traits<Container> mutable_traits;
|
||||
typedef iterator_pair_traits<Container const> const_traits; // ?
|
||||
typedef iterator_range_traits<Container> mutable_traits;
|
||||
typedef iterator_range_traits<Container const> const_traits; // ?
|
||||
|
||||
public:
|
||||
typedef default_algorithms<mutable_traits> mutable_algorithms;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// -*- mode:c++ -*-
|
||||
//
|
||||
// Header file container_traits.hpp
|
||||
//
|
||||
// Traits information about entire containers for use in determining
|
||||
@@ -92,11 +90,11 @@ namespace boost { namespace python { namespace indexing {
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Traits for the iterator_pair container emulator
|
||||
// Traits for the iterator_range container emulator
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename IteratorPair>
|
||||
struct iterator_pair_traits : public base_container_traits<IteratorPair>
|
||||
template<typename IteratorRange>
|
||||
struct iterator_range_traits : public base_container_traits<IteratorRange>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// -*- mode:c++ -*-
|
||||
//
|
||||
// Header file iterator_pair.hpp
|
||||
// Header file iterator_range.hpp
|
||||
//
|
||||
// Emulate an STL container using a pair of iterators. Doesn't support
|
||||
// insertion or deletion, for the obvious reasons.
|
||||
@@ -13,13 +11,14 @@
|
||||
//
|
||||
// History
|
||||
// =======
|
||||
// 2003/ 9/ 9 rmg File creation
|
||||
// 2003/ 9/ 9 rmg File creation as iterator_pair.hpp
|
||||
// 2003/10/27 rmg Renamed iterator_range.hpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
#ifndef BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP
|
||||
#define BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP
|
||||
#ifndef BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP
|
||||
#define BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
@@ -29,7 +28,7 @@
|
||||
|
||||
namespace boost { namespace python { namespace indexing {
|
||||
template<typename Iterator>
|
||||
class iterator_pair
|
||||
class iterator_range
|
||||
{
|
||||
private:
|
||||
typedef typename boost::call_traits<Iterator>::param_type iterator_param;
|
||||
@@ -45,7 +44,7 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
typedef iterator const_iterator;
|
||||
// Can't tell what the const version of our iterator should
|
||||
// be. The client code will have to instantiate iterator_pair
|
||||
// be. The client code will have to instantiate iterator_range
|
||||
// directly with a const_iterator if that's what it wants.
|
||||
|
||||
// Also can't provide: allocator_type, reverse_iterator or
|
||||
@@ -54,8 +53,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
// reference and pointer if Iterator is itself a const_iterator.
|
||||
|
||||
public:
|
||||
iterator_pair (iterator_param, iterator_param);
|
||||
iterator_pair (std::pair<iterator, iterator> const &);
|
||||
iterator_range (iterator_param, iterator_param);
|
||||
iterator_range (std::pair<iterator, iterator> const &);
|
||||
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
@@ -72,7 +71,7 @@ namespace boost { namespace python { namespace indexing {
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
iterator_pair<Iterator>::iterator_pair (
|
||||
iterator_range<Iterator>::iterator_range (
|
||||
iterator_param begin, iterator_param end)
|
||||
: m_begin (begin)
|
||||
, m_end (end)
|
||||
@@ -80,37 +79,37 @@ namespace boost { namespace python { namespace indexing {
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
iterator_pair<Iterator>
|
||||
::iterator_pair (std::pair<iterator, iterator> const &pair)
|
||||
iterator_range<Iterator>
|
||||
::iterator_range (std::pair<iterator, iterator> const &pair)
|
||||
: m_begin (pair.first)
|
||||
, m_end (pair.second)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename iterator_pair<Iterator>::iterator
|
||||
iterator_pair<Iterator>::begin() const
|
||||
typename iterator_range<Iterator>::iterator
|
||||
iterator_range<Iterator>::begin() const
|
||||
{
|
||||
return m_begin;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename iterator_pair<Iterator>::iterator
|
||||
iterator_pair<Iterator>::end() const
|
||||
typename iterator_range<Iterator>::iterator
|
||||
iterator_range<Iterator>::end() const
|
||||
{
|
||||
return m_end;
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename iterator_pair<Iterator>::size_type
|
||||
iterator_pair<Iterator>::size() const
|
||||
typename iterator_range<Iterator>::size_type
|
||||
iterator_range<Iterator>::size() const
|
||||
{
|
||||
return std::distance (begin(), end());
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename iterator_pair<Iterator>::reference
|
||||
iterator_pair<Iterator>::operator[](size_type index) const
|
||||
typename iterator_range<Iterator>::reference
|
||||
iterator_range<Iterator>::operator[](size_type index) const
|
||||
{
|
||||
iterator temp (begin());
|
||||
std::advance (temp, index);
|
||||
@@ -118,13 +117,13 @@ namespace boost { namespace python { namespace indexing {
|
||||
}
|
||||
|
||||
template<typename Iterator>
|
||||
typename iterator_pair<Iterator>::reference
|
||||
iterator_pair<Iterator>::at (size_type index) const
|
||||
typename iterator_range<Iterator>::reference
|
||||
iterator_range<Iterator>::at (size_type index) const
|
||||
{
|
||||
if (index >= size())
|
||||
{
|
||||
throw std::out_of_range
|
||||
(std::string ("iterator_pair: index out of range"));
|
||||
(std::string ("iterator_range: index out of range"));
|
||||
}
|
||||
|
||||
else
|
||||
@@ -144,4 +143,4 @@ namespace boost { namespace python { namespace indexing {
|
||||
}
|
||||
} } }
|
||||
|
||||
#endif // BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP
|
||||
#endif // BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP
|
||||
Reference in New Issue
Block a user