[gameprogrammer] Re: General Purpose Double Linked List Class

On Sun, 26 Feb 2006 20:19:30 +0100 (CET), "Torsten Giebl"
<wizard@xxxxxxxxxxxxxxx> said:
> 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 :-)

What do you mean, "use STL generally"?  It's perfectly possible to use
just the <list> header and std::list class without being forced to use
the rest of STL.  Though it seems like a waste of time to write your own
list algorithms when there are good ones already provided in the
library.

> But is the way i tried to use STL correct ?
> Okay, it is not the best programming style.

Well, yeah, it looks mostly OK though not pretty.

I don't agree with a list having a 'current element' (which is what you
use the iterator for).  What if you want to traverse the same list twice
at the same time - for instance, it's a list of polygons and you want to
work out intersections between combinations of all the elements in the
list?  There's no easy way to do that in your system.

The way STL does it as standard, with iterators which are external to
the list, is more general and allows full flexibility in the face of
changing requirements.  I really think that's the way you should do it.

Dave.
-- 
  Dave Slutzkin
  Melbourne, Australia
  daveslutzkin@xxxxxxxxxxx



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


Other related posts: