ReactOS 0.4.15-dev-7924-g5949c20
_iterator.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
5 *
6 * Copyright (c) 1996-1998
7 * Silicon Graphics Computer Systems, Inc.
8 *
9 * Copyright (c) 1997
10 * Moscow Center for SPARC Technology
11 *
12 * Copyright (c) 1999
13 * Boris Fomitchev
14 *
15 * This material is provided "as is", with absolutely no warranty expressed
16 * or implied. Any use is at your own risk.
17 *
18 * Permission to use or copy this software for any purpose is hereby granted
19 * without fee, provided the above notices are retained on all copies.
20 * Permission to modify the code and to distribute modified code is granted,
21 * provided the above notices are retained, and a notice that the code was
22 * modified is included with the above copyright notice.
23 *
24 */
25
26/* NOTE: This is an internal header file, included by other STL headers.
27 * You should not attempt to use it directly.
28 */
29
30#ifndef _STLP_INTERNAL_ITERATOR_H
31#define _STLP_INTERNAL_ITERATOR_H
32
33#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
34# include <stl/_iterator_base.h>
35#endif
36
38
39#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
40// This is the new version of reverse_iterator, as defined in the
41// draft C++ standard. It relies on the iterator_traits template,
42// which in turn relies on partial specialization. The class
43// reverse_bidirectional_iterator is no longer part of the draft
44// standard, but it is retained for backward compatibility.
45
46template <class _Iterator>
47class reverse_iterator :
48 public iterator<typename iterator_traits<_Iterator>::iterator_category,
49 typename iterator_traits<_Iterator>::value_type,
50 typename iterator_traits<_Iterator>::difference_type,
51 typename iterator_traits<_Iterator>::pointer,
52 typename iterator_traits<_Iterator>::reference> {
53protected:
54 _Iterator current;
56public:
58 // pointer type required for arrow operator hidden behind _STLP_DEFINE_ARROW_OPERATOR:
61 typedef _Iterator iterator_type;
62public:
64 explicit reverse_iterator(iterator_type __x) : current(__x) {}
65 reverse_iterator(const _Self& __x) : current(__x.current) {}
66 _Self& operator = (const _Self& __x) { current = __x.base(); return *this; }
67# if defined (_STLP_MEMBER_TEMPLATES)
68 template <class _Iter>
70 template <class _Iter>
71 _Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; }
72# endif /* _STLP_MEMBER_TEMPLATES */
73
74 iterator_type base() const { return current; }
75 reference operator*() const {
76 _Iterator __tmp = current;
77 return *--__tmp;
78 }
80 _Self& operator++() {
81 --current;
82 return *this;
83 }
84 _Self operator++(int) {
85 _Self __tmp = *this;
86 --current;
87 return __tmp;
88 }
89 _Self& operator--() {
90 ++current;
91 return *this;
92 }
93 _Self operator--(int) {
94 _Self __tmp = *this;
95 ++current;
96 return __tmp;
97 }
98
99 _Self operator+(difference_type __n) const { return _Self(current - __n); }
100 _Self& operator+=(difference_type __n) {
101 current -= __n;
102 return *this;
103 }
104 _Self operator-(difference_type __n) const { return _Self(current + __n); }
105 _Self& operator-=(difference_type __n) {
106 current += __n;
107 return *this;
108 }
109 reference operator[](difference_type __n) const { return *(*this + __n); }
110};
111
112template <class _Iterator>
115{ return __x.base() == __y.base(); }
116
117template <class _Iterator>
120{ return __y.base() < __x.base(); }
121
122# if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
123template <class _Iterator>
126{ return !(__x == __y); }
127
128template <class _Iterator>
131{ return __y < __x; }
132
133template <class _Iterator>
136{ return !(__y < __x); }
137
138template <class _Iterator>
141{ return !(__x < __y); }
142# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
143
144template <class _Iterator>
145# if defined (__SUNPRO_CC)
147# else
149# endif
152{ return __y.base() - __x.base(); }
153
154template <class _Iterator, class _DifferenceType>
156operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x)
157{ return x.operator+(n); }
158#endif
159
160template <class _Container>
162 : public iterator<output_iterator_tag, void, void, void, void> {
164protected:
165 //c is a Standard name (24.4.2.1), do no make it STLport naming convention compliant.
166 _Container *container;
167public:
168 typedef _Container container_type;
170
171 explicit back_insert_iterator(_Container& __x) : container(&__x) {}
172
173 _Self& operator=(const _Self& __other) {
174 container = __other.container;
175 return *this;
176 }
177 _Self& operator=(const typename _Container::value_type& __val) {
178 container->push_back(__val);
179 return *this;
180 }
181 _Self& operator*() { return *this; }
182 _Self& operator++() { return *this; }
183 _Self operator++(int) { return *this; }
184};
185
186template <class _Container>
189
190template <class _Container>
192 : public iterator<output_iterator_tag, void, void, void, void> {
194protected:
195 //c is a Standard name (24.4.2.3), do no make it STLport naming convention compliant.
196 _Container *container;
197public:
198 typedef _Container container_type;
200 explicit front_insert_iterator(_Container& __x) : container(&__x) {}
201
202 _Self& operator=(const _Self& __other) {
203 container = __other.container;
204 return *this;
205 }
206 _Self& operator=(const typename _Container::value_type& __val) {
207 container->push_front(__val);
208 return *this;
209 }
210 _Self& operator*() { return *this; }
211 _Self& operator++() { return *this; }
212 _Self operator++(int) { return *this; }
213};
214
215template <class _Container>
218
219template <class _Container>
221 : public iterator<output_iterator_tag, void, void, void, void> {
223protected:
224 //container is a Standard name (24.4.2.5), do no make it STLport naming convention compliant.
225 _Container *container;
226 typename _Container::iterator _M_iter;
227public:
228 typedef _Container container_type;
230 insert_iterator(_Container& __x, typename _Container::iterator __i)
231 : container(&__x), _M_iter(__i) {}
232
233 _Self& operator=(_Self const& __other) {
234 container = __other.container;
235 _M_iter = __other._M_iter;
236 return *this;
237 }
238 _Self& operator=(const typename _Container::value_type& __val) {
239 _M_iter = container->insert(_M_iter, __val);
240 ++_M_iter;
241 return *this;
242 }
243 _Self& operator*() { return *this; }
244 _Self& operator++() { return *this; }
245 _Self& operator++(int) { return *this; }
246};
247
248template <class _Container, class _Iterator>
250inserter(_Container& __x, _Iterator __i) {
251 typedef typename _Container::iterator __iter;
252 return insert_iterator<_Container>(__x, __iter(__i));
253}
254
256
257#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
258# include <stl/_iterator_old.h>
259#endif
260
261#endif /* _STLP_INTERNAL_ITERATOR_H */
262
263// Local Variables:
264// mode:C++
265// End:
#define reverse_iterator
Definition: _abbrevs.h:34
return __n
Definition: _algo.h:75
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
Definition: _alloc.h:384
#define _STLP_CALL
Definition: _bc.h:131
bool _STLP_CALL operator>(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:158
bool _STLP_CALL operator>=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:164
bool _STLP_CALL operator<=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:161
complex< _Tp > _STLP_CALL operator-(const complex< _Tp > &__z)
Definition: _complex.h:622
complex< _Tp > _STLP_CALL operator*(const _Tp &__x, const complex< _Tp > &__z)
Definition: _complex.h:644
front_insert_iterator< _Container > _STLP_CALL front_inserter(_Container &__x)
Definition: _iterator.h:216
insert_iterator< _Container > _STLP_CALL inserter(_Container &__x, _Iterator __i)
Definition: _iterator.h:250
back_insert_iterator< _Container > _STLP_CALL back_inserter(_Container &__x)
Definition: _iterator.h:187
#define _STLP_DEFINE_ARROW_OPERATOR
rope< _CharT, _Alloc > & operator+=(rope< _CharT, _Alloc > &__left, const rope< _CharT, _Alloc > &__right)
Definition: _rope.h:2202
CHString WINAPI operator+(CHSTRING_WCHAR ch, const CHString &string)
Definition: chstring.cpp:1356
back_insert_iterator< _Container > _Self
Definition: _iterator.h:163
_Self & operator=(const _Self &__other)
Definition: _iterator.h:173
_Container * container
Definition: _iterator.h:166
_Container container_type
Definition: _iterator.h:168
_Self & operator=(const typename _Container::value_type &__val)
Definition: _iterator.h:177
back_insert_iterator(_Container &__x)
Definition: _iterator.h:171
_Self operator++(int)
Definition: _iterator.h:183
_Self & operator*()
Definition: _iterator.h:181
output_iterator_tag iterator_category
Definition: _iterator.h:169
_Self & operator++()
Definition: _iterator.h:182
front_insert_iterator(_Container &__x)
Definition: _iterator.h:200
_Self operator++(int)
Definition: _iterator.h:212
_Self & operator=(const _Self &__other)
Definition: _iterator.h:202
_Container * container
Definition: _iterator.h:196
_Self & operator++()
Definition: _iterator.h:211
output_iterator_tag iterator_category
Definition: _iterator.h:199
_Container container_type
Definition: _iterator.h:198
front_insert_iterator< _Container > _Self
Definition: _iterator.h:193
_Self & operator=(const typename _Container::value_type &__val)
Definition: _iterator.h:206
output_iterator_tag iterator_category
Definition: _iterator.h:229
_Self & operator++(int)
Definition: _iterator.h:245
_Self & operator=(_Self const &__other)
Definition: _iterator.h:233
_Self & operator++()
Definition: _iterator.h:244
_Self & operator=(const typename _Container::value_type &__val)
Definition: _iterator.h:238
insert_iterator< _Container > _Self
Definition: _iterator.h:222
_Container * container
Definition: _iterator.h:225
_Container container_type
Definition: _iterator.h:228
_Self & operator*()
Definition: _iterator.h:243
_Container::iterator _M_iter
Definition: _iterator.h:226
insert_iterator(_Container &__x, typename _Container::iterator __i)
Definition: _iterator.h:230
reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > _Self
_Reference operator[](_Distance __n) const
_Self & operator--()
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
_RandomAccessIterator base() const
_Distance difference_type
_Self & operator-=(_Distance __n)
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729
GLsizei const GLvoid * pointer
Definition: glext.h:5848
GLint reference
Definition: glext.h:11729
struct task_struct * current
Definition: linux.c:32
_Iterator::reference reference
_Iterator::difference_type difference_type
_Iterator::pointer pointer
bool operator<(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:126
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122