I just started learning java. I already know C++ and python. In order to learn Java, I am kinda drawing analogies from what I know in C++. I was an avid user of STL libraries in C++ (vectors, deques, stacks, hashmaps) http://www.sgi.com/tech/stl/stl_introduction.html
At the same time, python also have standard dicts, lists etc easily figurable in their docs.
I have been googling lately to find STL equivalent in Java but am unable to find so? Can someone point me to right resources?
C++ has STL, the Standard Template Library, and Java has the Collections classes.
STL vs. containers: C++ provides well-designed STLs, whereas Java has Containers. The benefit of containers over STLs is that there are a few situations where STL doesn't have a direct solution.
STL include performance as part of the interface requirements. This is not normally the case for java collections. In Java, the algorithms are organized by container, while in STL the algorithms are independent of the container on which they operate. STL uses value semantics so that assignment copies a collection.
Use std::set , which is typically implemented as a binary search tree. Its insert() , erase() and find() methods are logarithmic in size, but can do better if a hint is given. The logarithmic complexity is reffered to the the Java TreeSet.
Important notice: the mentioned associations have similar API but may have different asymptotics of operations and implementation.
Notice: j.u
means java.util
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With