Sign in to follow this  
adtheice

dictionary vs list vs um something

Recommended Posts

adtheice    122
Ok currently i'm using the standard libraries vector container. what i need is something similar to a dictionary, i ask for a specific name and i'm passed the object that relates to that name. while i need this i _also_ need to be able to traverse the collection in order (backwards and forwards) and finally i need to be able to insert and remove items into the collection in specific order. I was thinking of using a dictionary collection then having a list inside the collection that stores the order of traversal then when you ask to traverse the list it simply returns the dictionary items in the order of the list. anyone have a different suggestion?

Share this post


Link to post
Share on other sites
adtheice    122
c++ sorry, i assumed it was clear when i said i was using the standard template library.

but now that i think about it other languages have a standard library also don't they? =P silly me.

Share this post


Link to post
Share on other sites
SiCrane    11839
By "dictionary collection" do you mean std::map then? std::map will let you iterate over the elements in order, both backwards and forwards.

Share this post


Link to post
Share on other sites
adtheice    122
this will work perfectly. see thats why i was asking. i rarely ever used c++ so i knew i was missing stuff from the standard library that i needed to use.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this