data containers
Jarrett Billingsley
kb3ctd2 at yahoo.com
Wed Jul 2 20:47:04 PDT 2008
"Moritz" <mpipahl at gspgmbh.com> wrote in message
news:g4gqge$27fi$1 at digitalmars.com...
> Hello,
>
> Im currently working on a gui framework for my game, and Im trying to find
> a versatile way to build my screens.
>
> I thought about a generic "Screen" class, which has functions like
> "add_element()" to insert a sprite or text into a layer on the screen.
>
> Rendering is then done from the lowest layer to the highest one.
> My question is now how I can implement these Layers, since I didnt find
> LikedLists or Hastables in Phobos.
>
> My Idea in C++ would be to have a hashtable int to linked list, which
> gives me the linked list for a layer upon inserting the layer number, and
> the linked list then contains my ScreenObjects (a base class for images,
> text, buttons and so on).
> What would be the best way to do this in D?
Well, hashtables are built into the language, though they are not
necessarily the most performant implementation.
List[int] table;
Phobos doesn't have any built-in data structures, like hashtables or linked
lists. Tango does. How necessary they are, I don't know, I've never
actually used them. Most of the stuff I need to get done, I can get done
with dynamic arrays and associative arrays. And really, if you can't type
up a linked list in about 30 seconds, .. well, good luck to you.
More information about the Digitalmars-d-learn
mailing list