[gameprogrammer] Re: General Purpose Double Linked List Class

sÃn, 26 02 2006 kl. 23:20 +0100, skrev Torsten Giebl:
> > I see that you maintain an "internal" iterator in your class, is there a
> > particular reason for doing this? PHP does this to, although i've never
> > understood why, things becomes much more simpler without (in my oppinion).
> 
> Jup. As i have functions like Get_Next_Element,
> i need some iterator, or not ?
Yes, basically, the idea is that STL iterators are just used like old C
array "iterators" - a truth with modifications, put pretty simple, e.g.:

List l;
for ( ListIterator it = l.begin(); it != l.end(); it++ ) {
    // Do stuff with each element, the value of the current element
    // Can be accessed as (*it).
    //
    // A cool thing is that if each element is an object, you can use
    // the -> operator to access the object's members in an easy way.
    // e.g.: it->objectFunction();
}

> > If you decide on still using your own class, you should change the
> > Is_Empty method to just return The_Actual_List.empty() which has
> > complexity O(1), while .size() has complexity O(n) - or at least it is
> > allowed to have complexity up to O(n) in the STL standard.
> 
> Thanks for the tip.
No problem, oh, and a good source for these kind of things are mentioned
here:
http://www.sgi.com/tech/stl/

-- 
Rasmus Toftdahl Olesen <halfdan@xxxxxxxxxxxx>
halfdans.net



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: