Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 1 and Version 2 of code/doc/ObjectListIterator


Ignore:
Timestamp:
Sep 27, 2008, 4:06:12 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ObjectListIterator

    v1 v2  
    88'''Important''': Always use !ObjectListIterator instead of Iterator if you know which class you want to iterate through.
    99
    10 == Example ==
     10== Examples ==
    1111{{{
    1212for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin();
     
    1717}
    1818}}}
     19
     20
     21
     22The following example uses the class-tree below.
     23
     24{{{
     25#!cpp
     26new A1();
     27new A1();
     28new A1();
     29
     30new A3();
     31new A3B1();
     32new A3B1C1();
     33
     34int count = 0;
     35for (ObjectListIterator<BaseObject> it = ObjectList<BaseObject>::begin();
     36                                    it != ObjectList<BaseObject>::end(); ++it)
     37{
     38  count++;
     39}
     40std::cout << "BaseObject: " << count << std::endl;
     41
     42count = 0;
     43for (ObjectListIterator<A1> it = ObjectList<A1>::begin();
     44                            it != ObjectList<A1>::end(); ++it)
     45{
     46  count++;
     47}
     48std::cout << "A1:         " << count << std::endl;
     49
     50count = 0;
     51for (ObjectListIterator<A3B1> it = ObjectList<A3B1>::begin();
     52                              it != ObjectList<A3B1>::end(); ++it)
     53{
     54  count++;
     55}
     56std::cout << "A3B1:       " << count << std::endl;
     57
     58/*
     59return:
     60BaseObject: 6
     61A1:         3
     62A3B1:       2
     63*/
     64}}}
     65
     66[[Image(Core:testclass_tree.gif)]]