[gameprogrammer] Re: General Purpose Double Linked List Class

sÃn, 26 02 2006 kl. 20:19 +0100, skrev Torsten Giebl:
> Hello !
> 
> 
> Thanks for your answer. I do not want to
> use STL generally in my game, i just wanted
> to throw something in to get a doubly linked list :-)
> 
> But is the way i tried to use STL correct ?
> Okay, it is not the best programming style.
There is nothing "incorrect" about using STL as you do, but as Tom
suggested what your class is doing can be done in one line:
typedef std::list<void*> List;

You can then either define an "ListIterator" as:
typedef List::iterator ListIterator
or just use it normally.

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).

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.

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



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


Other related posts: