2001-06-28 01:09:53 +08:00
|
|
|
// Iterators -*- C++ -*-
|
|
|
|
|
|
|
|
// Copyright (C) 2001 Free Software Foundation, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
|
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
2000-10-05 19:27:02 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994
|
|
|
|
* Hewlett-Packard Company
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation. Hewlett-Packard Company makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1996-1998
|
|
|
|
* Silicon Graphics Computer Systems, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation. Silicon Graphics makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
c_io_stdio.h: Correct grammar in comments.
2001-11-02 Phil Edwards <pme@gcc.gnu.org>
* config/io/c_io_stdio.h: Correct grammar in comments.
* docs/doxygen/Intro.3: Expand "top-level" man page.
* docs/doxygen/doxygroups.cc: New module definitions (comments).
* docs/doxygen/mainpage.doxy: Tweaks.
* docs/doxygen/run_doxygen: Update Doxygen version, massage man pages.
Add @file hooks so that headers are considered to be documented.
* include/bits/basic_ios.h, include/bits/basic_file.h,
include/bits/basic_string.h, include/bits/boost_concept_check.h,
include/bits/char_traits.h, include/bits/codecvt.h,
include/bits/concept_check.h, include/bits/cpp_type_traits.h,
include/bits/fpos.h, include/bits/gslice.h, include/bits/gslice_array.h,
include/bits/indirect_array.h, include/bits/ios_base.h,
include/bits/locale_facets.h, include/bits/localefwd.h,
include/bits/mask_array.h, include/bits/pthread_allocimpl.h,
include/bits/slice.h, include/bits/slice_array.h,
include/bits/std_algorithm.h, include/bits/std_bitset.h,
include/bits/std_complex.h, include/bits/std_deque.h,
include/bits/std_fstream.h, include/bits/std_functional.h,
include/bits/std_iomanip.h, include/bits/std_ios.h,
include/bits/std_iosfwd.h, include/bits/std_iostream.h,
include/bits/std_istream.h, include/bits/std_iterator.h,
include/bits/std_limits.h, include/bits/std_list.h,
include/bits/std_locale.h, include/bits/std_map.h,
include/bits/std_memory.h, include/bits/std_numeric.h,
include/bits/std_ostream.h, include/bits/std_queue.h,
include/bits/std_set.h, include/bits/std_sstream.h,
include/bits/std_stack.h, include/bits/std_streambuf.h,
include/bits/std_string.h, include/bits/std_utility.h,
include/bits/std_valarray.h, include/bits/std_vector.h,
include/bits/stl_algo.h, include/bits/stl_alloc.h,
include/bits/stl_bvector.h, include/bits/stl_construct.h,
include/bits/stl_deque.h, include/bits/stl_heap.h,
include/bits/stl_iterator.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_iterator_base_types.h, include/bits/stl_list.h,
include/bits/stl_map.h, include/bits/stl_multimap.h,
include/bits/stl_multiset.h, include/bits/stl_numeric.h,
include/bits/stl_pair.h, include/bits/stl_pthread_alloc.h,
include/bits/stl_queue.h, include/bits/stl_raw_storage_iter.h,
include/bits/stl_relops.h, include/bits/stl_set.h,
include/bits/stl_stack.h, include/bits/stl_tempbuf.h,
include/bits/stl_threads.h, include/bits/stl_tree.h,
include/bits/stl_uninitialized.h, include/bits/stl_vector.h,
include/bits/stream_iterator.h, include/bits/streambuf_iterator.h,
include/bits/stringfwd.h, include/bits/type_traits.h,
include/bits/valarray_array.h, include/bits/valarray_meta.h:
Add hooks, tweak comments only.
* include/bits/stl_algobase.h (swap, min, iter_swap): Also
document these functions.
* include/bits/stl_function.h: Tweak link comments.
From-SVN: r46717
2001-11-03 01:38:11 +08:00
|
|
|
/** @file stl_iterator.h
|
|
|
|
* This is an internal header file, included by other library headers.
|
|
|
|
* You should not attempt to use it directly.
|
2000-10-05 19:27:02 +08:00
|
|
|
*/
|
|
|
|
|
2001-12-07 04:29:31 +08:00
|
|
|
#ifndef __GLIBCPP_INTERNAL_ITERATOR_H
|
|
|
|
#define __GLIBCPP_INTERNAL_ITERATOR_H
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-03-05 05:34:02 +08:00
|
|
|
namespace std
|
|
|
|
{
|
2001-06-23 08:08:47 +08:00
|
|
|
// 24.4.1 Reverse iterators
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
class reverse_iterator
|
2001-12-27 05:56:17 +08:00
|
|
|
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
|
|
|
typename iterator_traits<_Iterator>::value_type,
|
|
|
|
typename iterator_traits<_Iterator>::difference_type,
|
|
|
|
typename iterator_traits<_Iterator>::pointer,
|
|
|
|
typename iterator_traits<_Iterator>::reference>
|
2001-06-23 08:08:47 +08:00
|
|
|
{
|
|
|
|
protected:
|
2001-12-27 05:56:17 +08:00
|
|
|
_Iterator _M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
public:
|
2001-06-26 15:01:09 +08:00
|
|
|
typedef _Iterator iterator_type;
|
|
|
|
typedef typename iterator_traits<_Iterator>::difference_type
|
|
|
|
difference_type;
|
|
|
|
typedef typename iterator_traits<_Iterator>::reference reference;
|
|
|
|
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
public:
|
2001-12-27 05:56:17 +08:00
|
|
|
reverse_iterator() { }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
explicit
|
2001-12-27 05:56:17 +08:00
|
|
|
reverse_iterator(iterator_type __x) : _M_current(__x) { }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator(const reverse_iterator& __x)
|
2001-12-27 05:56:17 +08:00
|
|
|
: _M_current(__x._M_current) { }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iter>
|
2001-06-23 08:08:47 +08:00
|
|
|
reverse_iterator(const reverse_iterator<_Iter>& __x)
|
2001-12-27 05:56:17 +08:00
|
|
|
: _M_current(__x.base()) { }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
iterator_type
|
2001-12-27 05:56:17 +08:00
|
|
|
base() const { return _M_current; }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
reference
|
|
|
|
operator*() const
|
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
_Iterator __tmp = _M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
return *--__tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer
|
|
|
|
operator->() const { return &(operator*()); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator++()
|
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
--_M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator
|
2001-06-23 08:08:47 +08:00
|
|
|
operator++(int)
|
|
|
|
{
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator __tmp = *this;
|
2001-12-27 05:56:17 +08:00
|
|
|
--_M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
return __tmp;
|
|
|
|
}
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator--()
|
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
++_M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator operator--(int)
|
2001-06-23 08:08:47 +08:00
|
|
|
{
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator __tmp = *this;
|
2001-12-27 05:56:17 +08:00
|
|
|
++_M_current;
|
2001-06-23 08:08:47 +08:00
|
|
|
return __tmp;
|
|
|
|
}
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator
|
2001-06-23 08:08:47 +08:00
|
|
|
operator+(difference_type __n) const
|
2001-12-27 05:56:17 +08:00
|
|
|
{ return reverse_iterator(_M_current - __n); }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator+=(difference_type __n)
|
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
_M_current -= __n;
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator
|
2001-06-23 08:08:47 +08:00
|
|
|
operator-(difference_type __n) const
|
2001-12-27 05:56:17 +08:00
|
|
|
{ return reverse_iterator(_M_current + __n); }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
reverse_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator-=(difference_type __n)
|
|
|
|
{
|
2001-06-26 15:01:09 +08:00
|
|
|
_M_current += __n;
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
reference
|
|
|
|
operator[](difference_type __n) const { return *(*this + __n); }
|
|
|
|
};
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator==(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return __x.base() == __y.base(); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator<(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return __y.base() < __x.base(); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator!=(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__x == __y); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator>(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return __y < __x; }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator<=(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline bool
|
|
|
|
operator>=(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline typename reverse_iterator<_Iterator>::difference_type
|
|
|
|
operator-(const reverse_iterator<_Iterator>& __x,
|
|
|
|
const reverse_iterator<_Iterator>& __y)
|
|
|
|
{ return __y.base() - __x.base(); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Iterator>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline reverse_iterator<_Iterator>
|
|
|
|
operator+(typename reverse_iterator<_Iterator>::difference_type __n,
|
|
|
|
const reverse_iterator<_Iterator>& __x)
|
|
|
|
{ return reverse_iterator<_Iterator>(__x.base() - __n); }
|
|
|
|
|
|
|
|
// 24.4.2.2.1 back_insert_iterator
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container>
|
2001-12-27 05:56:17 +08:00
|
|
|
class back_insert_iterator
|
2001-06-23 08:08:47 +08:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
|
|
|
{
|
|
|
|
protected:
|
2001-12-27 05:56:17 +08:00
|
|
|
_Container* _M_container;
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef _Container container_type;
|
|
|
|
|
|
|
|
explicit
|
2001-12-27 05:56:17 +08:00
|
|
|
back_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-27 05:22:57 +08:00
|
|
|
back_insert_iterator&
|
2001-10-20 02:39:00 +08:00
|
|
|
operator=(typename _Container::const_reference __value)
|
2001-06-23 08:08:47 +08:00
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
_M_container->push_back(__value);
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2001-06-27 05:22:57 +08:00
|
|
|
back_insert_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator*() { return *this; }
|
|
|
|
|
2001-06-27 05:22:57 +08:00
|
|
|
back_insert_iterator&
|
2001-06-23 08:08:47 +08:00
|
|
|
operator++() { return *this; }
|
|
|
|
|
2001-06-27 05:22:57 +08:00
|
|
|
back_insert_iterator
|
2001-06-23 08:08:47 +08:00
|
|
|
operator++(int) { return *this; }
|
|
|
|
};
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container>
|
2001-06-23 08:08:47 +08:00
|
|
|
inline back_insert_iterator<_Container>
|
|
|
|
back_inserter(_Container& __x)
|
|
|
|
{ return back_insert_iterator<_Container>(__x); }
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container>
|
2001-06-23 08:08:47 +08:00
|
|
|
class front_insert_iterator
|
2001-12-27 05:56:17 +08:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
2001-06-23 08:08:47 +08:00
|
|
|
{
|
|
|
|
protected:
|
2001-12-27 05:56:17 +08:00
|
|
|
_Container* _M_container;
|
2001-06-23 08:08:47 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef _Container container_type;
|
|
|
|
|
2001-12-27 05:56:17 +08:00
|
|
|
explicit front_insert_iterator(_Container& __x) : _M_container(&__x) { }
|
2001-06-27 05:22:57 +08:00
|
|
|
|
|
|
|
front_insert_iterator&
|
2001-10-20 02:39:00 +08:00
|
|
|
operator=(typename _Container::const_reference __value)
|
2001-06-27 05:22:57 +08:00
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
_M_container->push_front(__value);
|
2001-06-23 08:08:47 +08:00
|
|
|
return *this;
|
|
|
|
}
|
2001-06-27 05:22:57 +08:00
|
|
|
|
|
|
|
front_insert_iterator&
|
|
|
|
operator*() { return *this; }
|
|
|
|
|
|
|
|
front_insert_iterator&
|
|
|
|
operator++() { return *this; }
|
|
|
|
|
|
|
|
front_insert_iterator
|
|
|
|
operator++(int) { return *this; }
|
2001-06-23 08:08:47 +08:00
|
|
|
};
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container>
|
2001-12-27 05:56:17 +08:00
|
|
|
inline front_insert_iterator<_Container>
|
|
|
|
front_inserter(_Container& __x)
|
|
|
|
{ return front_insert_iterator<_Container>(__x); }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container>
|
2001-06-23 08:08:47 +08:00
|
|
|
class insert_iterator
|
2001-12-27 05:56:17 +08:00
|
|
|
: public iterator<output_iterator_tag, void, void, void, void>
|
2001-06-23 08:08:47 +08:00
|
|
|
{
|
|
|
|
protected:
|
2001-12-27 05:56:17 +08:00
|
|
|
_Container* _M_container;
|
2001-06-23 08:08:47 +08:00
|
|
|
typename _Container::iterator iter;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef _Container container_type;
|
|
|
|
|
|
|
|
insert_iterator(_Container& __x, typename _Container::iterator __i)
|
2001-12-27 05:56:17 +08:00
|
|
|
: _M_container(&__x), iter(__i) {}
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-27 05:22:57 +08:00
|
|
|
insert_iterator&
|
|
|
|
operator=(const typename _Container::const_reference __value)
|
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
iter = _M_container->insert(iter, __value);
|
2001-06-23 08:08:47 +08:00
|
|
|
++iter;
|
|
|
|
return *this;
|
|
|
|
}
|
2001-06-27 05:22:57 +08:00
|
|
|
|
|
|
|
insert_iterator&
|
|
|
|
operator*() { return *this; }
|
|
|
|
|
|
|
|
insert_iterator&
|
|
|
|
operator++() { return *this; }
|
|
|
|
|
|
|
|
insert_iterator&
|
|
|
|
operator++(int) { return *this; }
|
2001-06-23 08:08:47 +08:00
|
|
|
};
|
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _Container, typename _Iterator>
|
2001-12-27 05:56:17 +08:00
|
|
|
inline insert_iterator<_Container>
|
|
|
|
inserter(_Container& __x, _Iterator __i)
|
2001-06-26 15:01:09 +08:00
|
|
|
{
|
2001-12-27 05:56:17 +08:00
|
|
|
return insert_iterator<_Container>(__x,
|
|
|
|
typename _Container::iterator(__i));
|
2001-06-26 15:01:09 +08:00
|
|
|
}
|
2001-06-23 08:08:47 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
// This iterator adapter is 'normal' in the sense that it does not
|
2001-07-10 05:47:36 +08:00
|
|
|
// change the semantics of any of the operators of its iterator
|
2001-06-26 15:01:09 +08:00
|
|
|
// parameter. Its primary purpose is to convert an iterator that is
|
|
|
|
// not a class, e.g. a pointer, into an iterator that is a class.
|
|
|
|
// The _Container parameter exists solely so that different containers
|
|
|
|
// using this template can instantiate different types, even if the
|
|
|
|
// _Iterator parameter is the same.
|
|
|
|
template<typename _Iterator, typename _Container>
|
|
|
|
class __normal_iterator
|
|
|
|
: public iterator<typename iterator_traits<_Iterator>::iterator_category,
|
|
|
|
typename iterator_traits<_Iterator>::value_type,
|
|
|
|
typename iterator_traits<_Iterator>::difference_type,
|
|
|
|
typename iterator_traits<_Iterator>::pointer,
|
|
|
|
typename iterator_traits<_Iterator>::reference>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Iterator _M_current;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef typename iterator_traits<_Iterator>::difference_type
|
|
|
|
difference_type;
|
|
|
|
typedef typename iterator_traits<_Iterator>::reference reference;
|
|
|
|
typedef typename iterator_traits<_Iterator>::pointer pointer;
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
__normal_iterator() : _M_current(_Iterator()) { }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
explicit
|
|
|
|
__normal_iterator(const _Iterator& __i) : _M_current(__i) { }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
// Allow iterator to const_iterator conversion
|
|
|
|
template<typename _Iter>
|
|
|
|
inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
|
|
|
|
: _M_current(__i.base()) { }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
// Forward iterator requirements
|
|
|
|
reference
|
|
|
|
operator*() const { return *_M_current; }
|
|
|
|
|
|
|
|
pointer
|
|
|
|
operator->() const { return _M_current; }
|
|
|
|
|
|
|
|
__normal_iterator&
|
|
|
|
operator++() { ++_M_current; return *this; }
|
|
|
|
|
|
|
|
__normal_iterator
|
|
|
|
operator++(int) { return __normal_iterator(_M_current++); }
|
|
|
|
|
|
|
|
// Bidirectional iterator requirements
|
|
|
|
__normal_iterator&
|
|
|
|
operator--() { --_M_current; return *this; }
|
|
|
|
|
|
|
|
__normal_iterator
|
|
|
|
operator--(int) { return __normal_iterator(_M_current--); }
|
|
|
|
|
|
|
|
// Random access iterator requirements
|
|
|
|
reference
|
|
|
|
operator[](const difference_type& __n) const
|
|
|
|
{ return _M_current[__n]; }
|
|
|
|
|
|
|
|
__normal_iterator&
|
|
|
|
operator+=(const difference_type& __n)
|
|
|
|
{ _M_current += __n; return *this; }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
__normal_iterator
|
|
|
|
operator+(const difference_type& __n) const
|
|
|
|
{ return __normal_iterator(_M_current + __n); }
|
|
|
|
|
|
|
|
__normal_iterator&
|
|
|
|
operator-=(const difference_type& __n)
|
|
|
|
{ _M_current -= __n; return *this; }
|
|
|
|
|
|
|
|
__normal_iterator
|
|
|
|
operator-(const difference_type& __n) const
|
|
|
|
{ return __normal_iterator(_M_current - __n); }
|
|
|
|
|
|
|
|
difference_type
|
|
|
|
operator-(const __normal_iterator& __i) const
|
|
|
|
{ return _M_current - __i._M_current; }
|
|
|
|
|
|
|
|
const _Iterator&
|
|
|
|
base() const { return _M_current; }
|
|
|
|
};
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
// Forward iterator requirements
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() == __rhs.base(); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return !(__lhs == __rhs); }
|
2000-10-05 19:27:02 +08:00
|
|
|
|
|
|
|
// Random access iterator requirements
|
2001-06-26 15:01:09 +08:00
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __lhs.base() < __rhs.base(); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return __rhs < __lhs; }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return !(__rhs < __lhs); }
|
|
|
|
|
|
|
|
template<typename _IteratorL, typename _IteratorR, typename _Container>
|
|
|
|
inline bool
|
|
|
|
operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
|
|
|
|
const __normal_iterator<_IteratorR, _Container>& __rhs)
|
|
|
|
{ return !(__lhs < __rhs); }
|
|
|
|
|
|
|
|
template<typename _Iterator, typename _Container>
|
|
|
|
inline __normal_iterator<_Iterator, _Container>
|
2001-07-20 08:09:31 +08:00
|
|
|
operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n,
|
2001-06-26 15:01:09 +08:00
|
|
|
const __normal_iterator<_Iterator, _Container>& __i)
|
|
|
|
{ return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
|
2001-03-05 05:34:02 +08:00
|
|
|
} // namespace std
|
2000-10-05 19:27:02 +08:00
|
|
|
|
2001-06-26 15:01:09 +08:00
|
|
|
#endif
|
2000-10-05 19:27:02 +08:00
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// mode:C++
|
|
|
|
// End:
|