What C++ library provides Data structures API that match the ones provided by java.util.* as much as possible. Specifically, I am looking for the following DS and following Utility Functions:-
**DS**: Priority Queue, HashMap, TreeMap, HashSet,
TreeSet, ArrayList, String most importantly.
**Utility**: Arrays.* , Collections.*, Regex, FileHandling etc.
and other converters and algorithms like Binary Search, Sort, NthElement etc.
My guess is that Boost may be able to do all these, but I find it too bulky and is non-trivial to add it into a project, especially, when I want to quickly get started on something and when although the code would require all these data structures, the code overall is not going to be that huge to warrant spending lot of effort in setting up libraries.
An example would be if someon开发者_如何学Ce had to write a C++ program to do Network Flow Algorithm for a school assignment. I am sure I could come up with better examples, but this one's on top of my head.
Thanks Ajay
All of those containers are available in some form in the SC++L:
Priority Queue
std::priority_queue (this is actually a container adapter, rather than a container itself - that is, it works "on top of" another container, usuallystd::vector
orstd::deque
.HashMap
std::unordered_map (or if your compiler doesn't support C++0x, there'sboost::unordered_map
)TreeMap
std::mapHashSet
andTreeSet
are basically the same asHashMap
andTreeMap
, except the key and value are the same thing. However, there's alsostd::unordered_set
andstd::set
.ArrayList
is the venerable std::vectorString
is the venerable std::string. Many of the functions you get in the JavaString
class can be found in the Boost.Strings library.
Do not be afraid of setting up boost. In my experience, you set it up once and then use it over and over again in all of your projects. Also, all of the libraries that I mentioned above are header-only libraries. That means, you don't actually need to build/install any libraries, just references the headers.
For the other things, I'm not so sure, since I don't know Java all that well. At the end of the day, you're not going to find a library that's "just like Java, except written in C++" because that would be kind of pointless. A C++ library is written to play to C++'s strength, a Java library is written to play to Java's strengths. To try and shoehorn a library designed for one language into another doesn't make sense to me.
精彩评论