views:

61

answers:

1

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 someone 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

+6  A: 

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, usually std::vector or std::deque.
  • HashMap std::unordered_map (or if your compiler doesn't support C++0x, there's boost::unordered_map)
  • TreeMap std::map
  • HashSet and TreeSet are basically the same as HashMap and TreeMap, except the key and value are the same thing. However, there's also std::unordered_set and std::set.
  • ArrayList is the venerable std::vector
  • String is the venerable std::string. Many of the functions you get in the Java String 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.

Dean Harding
What about FileHandling support and about utility functions like converting stuff a int[] into vector<int> , vector<int> to int[] etc.?Does Boost have all those?
ajay
Dean Harding
+1 for the last sentence.
Billy ONeal
Thank you very much! This really helps a lot!
ajay