Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/core/Iterator.h @ 337

Last change on this file since 337 was 337, checked in by bknecht, 16 years ago

merged merger to FICN branch

File size: 1.4 KB
Line 
1#ifndef _Iterator_H2__
2#define _Iterator_H2__
3
4namespace orxonox
5{
6    template <class T>
7    class Iterator
8    {
9        public:
10            Iterator()
11            {
12                this->element_ = 0;
13            }
14
15            Iterator(ObjectListElement<T>* element)
16            {
17                this->element_ = element;
18            }
19
20            Iterator<T> operator++()
21            {
22                this->element_ = this->element_->next_;
23                return *this;
24            }
25
26            Iterator<T> operator--()
27            {
28                this->element_ = this->element_->prev_;
29                return *this;
30            }
31
32            T* operator*()
33            {
34                return this->element_->object_;
35            }
36
37            T* operator->() const
38            {
39                return this->element_->object_;
40
41            }
42
43            operator bool()
44            {
45                return (this->element_ != 0);
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
53                return (this->element_ != 0);
54            }
55
56        private:
57            ObjectListElement<T>* element_;
58    };
59}
60
61#endif
Note: See TracBrowser for help on using the repository browser.