Recommend a data structure for my GUI

Started by
2 comments, last by Emmanuel Deloget 18 years, 1 month ago
Hi, Like Orangytang, I am developing my own GUI library for use with directx I am a bit stuck tho, and wondered if anyone might be able to help. Which data structure should I use to hold a list of children of a window? It seems like I want everything, random access, speed, insertion and deletion at any point.... Am i being slow or is a std::vector fine.... Thanks Simon
Advertisement
I'm using std::list in my GUI implementation. This works neatly for all kind of things. I do have some special constructs for removing components during the GUI events (it's not a good idea to really do the delete if you're still in the components event handler).

I don't need random access, what would you use it for? Everything else is covered by std::list.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Yeah, list is the best option, I think. You don't really need random access as you will could do stuff with windows using their own handlers, instead of accessing the element by the container itself.
How many child will you have ? Unless you don't have to handle countless widgets, the choice of a container is rather simple: use the one you like. If, later, you show that the container is too slow to be usable, then change it.

Both vector and list fits the bill, but unless you really need a random access to your child widgets, I suggest you to use a list.

Regards,

This topic is closed to new replies.

Advertisement