Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 3 (modified by landauf, 16 years ago) (diff)

Iterator

TracNav(TracNav/TOC_Development)?

Description

The Iterator allows you to easily iterate through all objects in an ObjectList. An ObjectList stores all objects of a given class (and all derivatives). To start iterating, you need the first element in the ObjectList. This gets returned by ObjectList<ClassName>::begin().

Example

The following example uses the class-tree below.

new A1();
new A1();
new A1();

new A3();
new A3B1();
new A3B1C1();

int count = 0;
for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; ++it)
  count++;
std::cout << "BaseObject: " << count << std::endl;

count = 0;
for (Iterator<A1> it = ObjectList<A1>::begin(); it; ++it)
  count++;
std::cout << "A1:         " << count << std::endl;

count = 0;
for (Iterator<A3B1> it = ObjectList<A3B1>::begin(); it; ++it)
  count++;
std::cout << "A3B1:       " << count << std::endl;

/*
return:
BaseObject: 6
A1:         3
A3B1:       2
*/

No image "testclass_tree.gif" attached to Core

Attachments (1)

Download all attachments as: .zip