35 |
#if USE_EXCEPTIONS |
#if USE_EXCEPTIONS |
36 |
# include <stdexcept> |
# include <stdexcept> |
37 |
# include <string> |
# include <string> |
|
const std::string __err_msg_iterator_invalidated = "Pool/RTList iterator invalidated"; |
|
38 |
#endif // USE_EXCEPTIONS |
#endif // USE_EXCEPTIONS |
39 |
|
|
40 |
|
#if DEVMODE |
41 |
|
const std::string __err_msg_iterator_invalidated = "Pool/RTList iterator invalidated"; |
42 |
|
#endif |
43 |
|
|
44 |
// just symbol prototyping |
// just symbol prototyping |
45 |
template<typename T> class Pool; |
template<typename T> class Pool; |
46 |
template<typename T> class RTList; |
template<typename T> class RTList; |
82 |
|
|
83 |
/// prefix increment op. |
/// prefix increment op. |
84 |
inline _Iterator& operator++() { |
inline _Iterator& operator++() { |
85 |
#if DEVMODE |
#if DEVMODE |
86 |
#if USE_EXCEPTIONS |
if (!isValid()) { |
87 |
if (!isValid()) throw std::runtime_error(__err_msg_iterator_invalidated); |
#if USE_EXCEPTIONS |
88 |
#else |
throw std::runtime_error(__err_msg_iterator_invalidated); |
89 |
if (!isValid()) return *(_Iterator*)NULL; // force segfault if iterator became invalidated |
#else |
90 |
#endif // USE_EXCEPTIONS |
std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; |
91 |
|
return *(_Iterator*)NULL; // force segfault if iterator became invalidated |
92 |
|
#endif // USE_EXCEPTIONS |
93 |
|
} |
94 |
#endif // DEVMODE |
#endif // DEVMODE |
95 |
fallback = current; |
fallback = current; |
96 |
current = current->next; |
current = current->next; |
100 |
/// postfix increment op. |
/// postfix increment op. |
101 |
inline _Iterator operator++(int) { |
inline _Iterator operator++(int) { |
102 |
_Iterator preval = *this; |
_Iterator preval = *this; |
103 |
++*this; |
++*this; // use prefix operator implementation |
104 |
return preval; |
return preval; |
105 |
} |
} |
106 |
|
|
107 |
/// prefix decrement op. |
/// prefix decrement op. |
108 |
inline _Iterator& operator--() { |
inline _Iterator& operator--() { |
109 |
#if DEVMODE |
#if DEVMODE |
110 |
#if USE_EXCEPTIONS |
if (!isValid()) { |
111 |
if (!isValid()) throw std::runtime_error(__err_msg_iterator_invalidated); |
#if USE_EXCEPTIONS |
112 |
#else |
throw std::runtime_error(__err_msg_iterator_invalidated); |
113 |
if (!isValid()) return *(_Iterator*)NULL; // force segfault if iterator became invalidated |
#else |
114 |
#endif // USE_EXCEPTIONS |
std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; |
115 |
|
return *(_Iterator*)NULL; // force segfault if iterator became invalidated |
116 |
|
#endif // USE_EXCEPTIONS |
117 |
|
} |
118 |
#endif // DEVMODE |
#endif // DEVMODE |
119 |
fallback = current; |
fallback = current; |
120 |
current = current->prev; |
current = current->prev; |
124 |
/// postfix decrement op. |
/// postfix decrement op. |
125 |
inline _Iterator operator--(int) { |
inline _Iterator operator--(int) { |
126 |
_Iterator preval = *this; |
_Iterator preval = *this; |
127 |
--*this; |
--*this; // use prefix operator implementation |
128 |
return preval; |
return preval; |
129 |
} |
} |
130 |
|
|
131 |
inline T1& operator*() { |
inline T1& operator*() { |
132 |
#if DEVMODE |
#if DEVMODE |
133 |
#if USE_EXCEPTIONS |
if (!isValid()) { // if iterator became invalidated |
134 |
if (isValid()) return *current->data; |
#if USE_EXCEPTIONS |
135 |
else throw std::runtime_error(__err_msg_iterator_invalidated); |
throw std::runtime_error(__err_msg_iterator_invalidated); |
136 |
#else |
#else |
137 |
return *(isValid() ? current->data : (T1*)NULL); // force segfault if iterator became invalidated |
std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; |
138 |
#endif // USE_EXCEPTIONS |
return *((T1*)NULL); // force segfault if iterator became invalidated |
139 |
#else |
#endif // USE_EXCEPTIONS |
140 |
return *current->data; |
} |
141 |
#endif // DEVMODE |
#endif // DEVMODE |
142 |
|
return *current->data; |
143 |
|
|
144 |
} |
} |
145 |
|
|
146 |
inline T1* operator->() { |
inline T1* operator->() { |
147 |
#if DEVMODE |
#if DEVMODE |
148 |
#if USE_EXCEPTIONS |
if (!isValid()) { // if iterator became invalidated |
149 |
if (isValid()) return current->data; |
#if USE_EXCEPTIONS |
150 |
else throw std::runtime_error(__err_msg_iterator_invalidated); |
throw std::runtime_error(__err_msg_iterator_invalidated); |
151 |
#else |
#else |
152 |
return isValid() ? current->data : (T1*)NULL; // force segfault if iterator became invalidated |
std::cerr << __err_msg_iterator_invalidated << std::endl << std::flush; |
153 |
#endif // USE_EXCEPTIONS |
return (T1*)NULL; // force segfault if iterator became invalidated |
154 |
#else |
#endif // USE_EXCEPTIONS |
155 |
return current->data; |
} |
156 |
#endif // DEVMODE |
#endif // DEVMODE |
157 |
|
return current->data; |
158 |
} |
} |
159 |
|
|
160 |
inline bool operator==(const _Iterator<T1> other) { |
inline bool operator==(const _Iterator<T1> other) { |