Re: Can I compare references (in a sense of compareTo method)?
On Sep 21, 12:26 am, chucky <tomas.mik...@gmail.com> wrote:
Thank you guys, seems you have answered my question indirectly --
there is no way to get the address of an object :-).
On Sep 20, 11:42 pm, Daniel Pitts <googlegrou...@coloraura.com> wrote:
Now, the questions remains, if they don't have inherent order, why use
them in a TreeSet or TreeMap? Why not a standard HashSet/HashMap?
The main benefit of Tree* is that it maintains the order for you.
I don't care about the actual ordering, but I wanted to use Tree*
since I thought it would have smaller memory overhead than Hash*. I
don't care much about logarithmic complexity (which is btw.
guaranteed, while Hash operations don't guarantee constant
complexity), since I want to use it for small collections (<20
elements).
Why is HashSet/HashMap more standard than TreeSet/TreeMap?
T.
Hash doesn't have a huge memory overhead, and generally you shouldn't
worry about such things until they become a problem.
If you declare your sets/maps using the interface "Set<MyThing>" and
"Map<MyThing, OtherThing>", then you can switch between different
implementations.
HashSet and HashMap are the default choice, because they are on
average O(1) operations. TreeSet and TreeMap have a very specific
purpose, and that purpose is to guarantee and ordering of elements.