PPL  1.2
Ptr_Iterator_inlines.hh
Go to the documentation of this file.
1 /* Ptr_Iterator class implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Ptr_Iterator_inlines_hh
25 #define PPL_Ptr_Iterator_inlines_hh 1
26 
27 namespace Parma_Polyhedra_Library {
28 
29 namespace Implementation {
30 
31 template <typename P>
32 inline const P&
34  return p;
35 }
36 
37 template <typename P>
38 inline
40  : p(P()) {
41 }
42 
43 template <typename P>
44 inline
46  : p(q) {
47 }
48 
49 template <typename P>
50 template <typename Q>
51 inline
53  : p(q.base()) {
54 }
55 
56 template <typename P>
57 inline typename Ptr_Iterator<P>::reference
59  return *p;
60 }
61 
62 template <typename P>
63 inline typename Ptr_Iterator<P>::pointer
65  return p;
66 }
67 
68 template <typename P>
69 inline typename Ptr_Iterator<P>::reference
71  return p[m];
72 }
73 
74 template <typename P>
75 inline Ptr_Iterator<P>&
77  ++p;
78  return *this;
79 }
80 
81 template <typename P>
82 inline Ptr_Iterator<P>
84  return Ptr_Iterator(p++);
85 }
86 
87 template <typename P>
88 inline Ptr_Iterator<P>&
90  --p;
91  return *this;
92 }
93 
94 template <typename P>
95 inline Ptr_Iterator<P>
97  return Ptr_Iterator(p--);
98 }
99 
100 
101 template <typename P>
102 inline Ptr_Iterator<P>&
104  p += m;
105  return *this;
106 }
107 
108 template <typename P>
109 inline Ptr_Iterator<P>&
111  p -= m;
112  return *this;
113 }
114 
115 template <typename P>
116 inline typename Ptr_Iterator<P>::difference_type
118  return p - y.p;
119 }
120 
121 template <typename P>
122 inline Ptr_Iterator<P>
124  return Ptr_Iterator(p + m);
125 }
126 
127 template <typename P>
128 inline Ptr_Iterator<P>
130  return Ptr_Iterator(p - m);
131 }
132 
133 template<typename P, typename Q>
134 inline bool
136  return x.base() == y.base();
137 }
138 
139 template<typename P, typename Q>
140 inline bool
142  return x.base() != y.base();
143 }
144 
145 template<typename P, typename Q>
146 inline bool
147 operator<(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
148  return x.base() < y.base();
149 }
150 
151 template<typename P, typename Q>
152 inline bool
153 operator<=(const Ptr_Iterator<P>& x, const Ptr_Iterator<Q>& y) {
154  return x.base() <= y.base();
155 }
156 
157 template<typename P, typename Q>
158 inline bool
160  return x.base() > y.base();
161 }
162 
163 template<typename P, typename Q>
164 inline bool
166  return x.base() >= y.base();
167 }
168 
169 template<typename P, typename Q>
170 inline typename Ptr_Iterator<P>::difference_type
172  return x.base() - y.base();
173 }
174 
175 template<typename P>
176 inline Ptr_Iterator<P>
178  const Ptr_Iterator<P>& y) {
179  return Ptr_Iterator<P>(m + y.base());
180 }
181 
182 } // namespace Implementation
183 
184 } // namespace Parma_Polyhedra_Library
185 
186 #endif // !defined(PPL_Ptr_Iterator_inlines_hh)
pointer operator->() const
Indirect member selector.
Ptr_Iterator< P >::difference_type operator-(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
bool operator>(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
reference operator[](const difference_type m) const
Subscript operator.
Ptr_Iterator & operator--()
Prefix decrement operator.
A class to define STL const and non-const iterators from pointer types.
bool operator>=(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
Ptr_Iterator()
Default constructor: no guarantees.
difference_type operator-(const Ptr_Iterator &y) const
Returns the difference between *this and y.
std::iterator_traits< P >::reference reference
reference operator*() const
Dereference operator.
P p
The base pointer implementing the iterator.
bool operator==(const EList_Iterator< T > &x, const EList_Iterator< T > &y)
Returns true if and only if x and y are equal.
bool operator!=(const EList_Iterator< T > &x, const EList_Iterator< T > &y)
Returns true if and only if x and y are different.
Ptr_Iterator & operator++()
Prefix increment operator.
Ptr_Iterator & operator-=(const difference_type m)
Assignment-decrement operator.
Ptr_Iterator & operator+=(const difference_type m)
Assignment-increment operator.
The entire library is confined to this namespace.
Definition: version.hh:61
Ptr_Iterator operator+(const difference_type m) const
Returns the sum of *this and m.
std::iterator_traits< P >::difference_type difference_type
Ptr_Iterator< P > operator+(typename Ptr_Iterator< P >::difference_type m, const Ptr_Iterator< P > &y)
const P & base() const
Returns the hidden pointer.