Last change
on this file since 222 was
221,
checked in by landauf, 17 years ago
|
- made ObjectList double-linked to allow forward- and backward-iterating. its now a LI(F/L)O list.
- added an iterator to iterate through object-lists. you can iterate forwards and backwards.
iterating forwards is easy: you get "0 1 2 … last"
iterating backwards is a bit tricky: you still get "0" first, but then "last … 2 1".
thats caused by the structure of the for-loop: you get the first element before the iterator knows if you'll increase or decrease it
|
File size:
695 bytes
|
Line | |
---|
1 | #ifndef _ObjectList_H__ |
---|
2 | #define _ObjectList_H__ |
---|
3 | |
---|
4 | namespace orxonox |
---|
5 | { |
---|
6 | class OrxonoxClass; |
---|
7 | |
---|
8 | class ObjectListElement |
---|
9 | { |
---|
10 | public: |
---|
11 | ObjectListElement(OrxonoxClass* object); |
---|
12 | ~ObjectListElement(); |
---|
13 | |
---|
14 | OrxonoxClass* object_; |
---|
15 | ObjectListElement* next_; |
---|
16 | ObjectListElement* prev_; |
---|
17 | }; |
---|
18 | |
---|
19 | class ObjectList |
---|
20 | { |
---|
21 | public: |
---|
22 | ObjectList(); |
---|
23 | ~ObjectList(); |
---|
24 | void add(OrxonoxClass* object); |
---|
25 | void remove(OrxonoxClass* object, bool bIterateForwards = true); |
---|
26 | |
---|
27 | ObjectListElement* first_; |
---|
28 | ObjectListElement* last_; |
---|
29 | }; |
---|
30 | } |
---|
31 | |
---|
32 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.