| | 1 | = !ObjectListIterator = |
| | 2 | [[TracNav(TracNav/TOC_Development)]] |
| | 3 | |
| | 4 | The !ObjectListIterator of a given class T can iterate exactly through all objects of class T and inheritors. The only way to create such an iterator is by calling one of [wiki:ObjectList ObjectLists] functions begin, end, rbegin or rend, where the !ObjectList has to be of the same T as the !ObjectListIterator. |
| | 5 | |
| | 6 | Another way to iterate through object-lists is by using [wiki:Iterator]. !ObjectListIterator however is much more performant as it knows about the right class an therefore needs no dynamic-cast. That's why you should always remember: |
| | 7 | |
| | 8 | '''Important''': Always use !ObjectListIterator instead of Iterator if you know which class you want to iterate through. |
| | 9 | |
| | 10 | == Example == |
| | 11 | {{{ |
| | 12 | for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); |
| | 13 | it != ObjectList<myClass>::end(); ++it) |
| | 14 | { |
| | 15 | it->someFunction(...); |
| | 16 | myClass* myObject = *it; |
| | 17 | } |
| | 18 | }}} |