Boost contains dozens of libraries with widely varying purposes.
The first place to look for containers in C++ is the STL library, which is part of standard C++. They are nothing like Java containers AFAIK, which is great, because C++ is nothing like Java.
Last edited by D_Drmmr; January 30th, 2012 at 09:08 AM.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
C++ also has std::deque, which looks similar to std::vector but is different internally, and some adapters std::stack, std::queue, and std:riority_queue which are not containers but can be used to modify the interface of standard containers if desired.
Boost has some additional containers.
Last edited by Lindley; January 30th, 2012 at 10:09 AM.
Yes and no. Yes, in the sense that the typically expected usage of a std::map would be identical to that of a SortedMap. No, because the details of their interfaces are different, and in fact std::map is a concrete class template whereas SortedMap is an interface construct.
Originally Posted by lucky6969b
what is the equivalence for stdext::hash_map in Java?
If the name is any clue, then stdext::hash_map's rough equivalent in Java is obviously HashMap.
If the key is a primitive such as an int, and the natural notion of ordering is sufficient, then there is no need to do anything special to keep the container sorted.
One thing to watch out for: If you are using a string as the key, it must be a std::string or other string class defining operator< lexicographically. C-style strings, which are essentially just char arrays, will *not* provide the expected behavior when used as map keys (only the pointer values will be compared).
Since you presumably do not want to use the default "less than" comparison for std::string as provided by the overloaded operator<, how you do want to compare the strings? That is central to implementing this "less than" comparison function.