Original Post
Found out this rather nifty container and now I'm wondering wether I should switch from vector to this. Problem: I need access to creature based on creatures ID. Creatures get added and deleted a lot. There could potentially be thousands of of creatures. First I thought I would sort vector with STL-algorithm after creating(and deleting) all the creatures that are going to be created/deleted and when needing creature with ID of x some search algorithm that takes advantage of the fact list is sorted so that smallest ID is first and largest last gives me right vector index. Should be faster than looping through all the creatures every time I need certain creature right? However since that requires sort everytime creatures are added(atleast this can be done once per logic round) plus search everytime I wondered wasn't there alternative way and came upon map. Don't know how it's implemented but would this be faster(or atleast not meaningfully slower) than STL sort+some sort of search algorithm(binary is current thinking unless I find even better)? And I could do it like: map myCreatures; And then do like map[myCreature.getId()]=myCreature; right? (assuming myCreature is valid object of course) Anything else I would need to know? I would like to know potential pitfalls before switching from vectors to maps for everything that needs something like this.