source:
code/branches/objecthierarchie/src/Iterator.h
@
248
Last change on this file since 248 was 248, checked in by landauf, 17 years ago | |
---|---|
File size: 1.4 KB |
Rev | Line | |
---|---|---|
[221] | 1 | #ifndef _Iterator_H__ |
2 | #define _Iterator_H__ | |
3 | ||
4 | namespace orxonox | |
5 | { | |
6 | template <class T> | |
7 | class Iterator | |
8 | { | |
9 | public: | |
10 | Iterator() | |
11 | { | |
[248] | 12 | this->element_ = 0; |
[221] | 13 | } |
14 | ||
[248] | 15 | Iterator(ObjectListElement<T>* element) |
[221] | 16 | { |
[248] | 17 | this->element_ = element; |
[221] | 18 | } |
19 | ||
[225] | 20 | Iterator<T> operator++() |
21 | { | |
[248] | 22 | this->element_ = this->element_->next_; |
[225] | 23 | return *this; |
24 | } | |
25 | ||
26 | Iterator<T> operator--() | |
27 | { | |
[248] | 28 | this->element_ = this->element_->prev_; |
[225] | 29 | return *this; |
[221] | 30 | } |
31 | ||
32 | T* operator*() | |
33 | { | |
[248] | 34 | return this->element_->object_; |
[221] | 35 | } |
36 | ||
37 | T* operator->() const | |
38 | { | |
[248] | 39 | return this->element_->object_; |
[221] | 40 | |
41 | } | |
42 | ||
43 | operator bool() | |
44 | { | |
[248] | 45 | return (this->element_ != 0); |
[221] | 46 | } |
47 | ||
48 | bool operator!=(int compare) | |
49 | { | |
50 | if (compare != 0) | |
51 | std::cout << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works.\n"; | |
52 | ||
[248] | 53 | return (this->element_ != 0); |
[221] | 54 | } |
55 | ||
56 | private: | |
[248] | 57 | ObjectListElement<T>* element_; |
[221] | 58 | }; |
59 | } | |
60 | ||
61 | #endif |
Note: See TracBrowser
for help on using the repository browser.