| | 73 | }}} |
| | 74 | |
| | 75 | === Iterating through existing objects === |
| | 76 | '''getObjects()''' returns a pointer to an [wiki:ObjectListBase], containing all objects of the class. You can iterate through them with an [wiki:Iterator]: |
| | 77 | {{{ |
| | 78 | Identifier* identifier = Class(SomeClass); |
| | 79 | |
| | 80 | Iterator it = identifier->getObjects()->begin(); |
| | 81 | for (; it != identifier->getObjects()->end(); ++it) |
| | 82 | { |
| | 83 | it->callAFunction(); |
| | 84 | } |
| | 85 | }}} |
| | 86 | |
| | 87 | '''Important''': If you know at compiletime which class you want to iterate through, use [wiki:ObjectListIterator], because it's much faster: |
| | 88 | {{{ |
| | 89 | ObjectList<SomeClass>::iterator it = ObjectList<SomeClass>::begin(); |
| | 90 | for (; it != ObjectList<SomeClass>::end(); ++it) |
| | 91 | { |
| | 92 | it->callAFunction(); |
| | 93 | } |