Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 20, 2007, 2:57:59 AM (12 years ago)
Author:
landauf
Message:
  • 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:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchie/src/orxonox.cc

    r219 r221  
    500500        delete test8_03;
    501501*/
    502 
     502/*
    503503        std::cout << "Test 9\n";
    504504        std::cout << "1\n";
     
    526526        delete test9_05;
    527527        delete test9_06;
     528*/
     529        std::cout << "Test 10\n";
     530        Identifier* test9_01 = Class(A1B2);
     531        Identifier* test9_02 = Class(A2);
     532        Identifier* test9_03 = Class(A3B1C1);
     533
     534
     535        BaseObject* test9_04 = test9_01->fabricate();
     536        BaseObject* test9_05 = test9_02->fabricate();
     537        BaseObject* test9_06 = test9_03->fabricate();
     538
     539        BaseObject* test9_07;
     540        for (int i = 0; i < 10; i++)
     541            test9_07 = Factory("A1B1C1");
     542
     543        std::cout << "1\n";
     544        int count = 0;
     545        for (Iterator<BaseObject> it; it != 0; it++)
     546            count++;
     547        std::cout << "Anzahl BaseObjects: " << count << "\n";
     548
     549        count = 0;
     550        for (Iterator<A1> it; it != 0; it++)
     551            count++;
     552        std::cout << "Anzahl A1: " << count << "\n";
     553
     554        count = 0;
     555        for (Iterator<A1B1> it; it; it++)
     556            count++;
     557        std::cout << "Anzahl A1B1: " << count << "\n";
     558
     559        count = 0;
     560        for (Iterator<A1B1C1> it; it; it++)
     561            count++;
     562        std::cout << "Anzahl A1B1C1: " << count << "\n";
     563
     564        count = 0;
     565        for (Iterator<A2> it; it; it++)
     566            count++;
     567        std::cout << "Anzahl A2: " << count << "\n";
     568
     569
     570        std::cout << "2\n";
     571        BaseObject* test9_08;
     572        for (int i = 0; i < 10; i++)
     573        {
     574            test9_08 = Factory("A2B1C1");
     575            test9_08->name_ = "A2B1C1#";
     576            test9_08->name_ += ('0' + i);
     577        }
     578
     579        for (Iterator<A2B1C1> it; it; it++)
     580            std::cout << "Name: " << it->name_ << "\n";
     581
     582        std::cout << "3\n";
     583        for (Iterator<A2B1C1> it; it; it--)
     584            std::cout << "Name: " << it->name_ << "\n";
     585
     586        std::cout << "4\n";
    528587
    529588      }
Note: See TracChangeset for help on using the changeset viewer.