constant time performance
I was reading at a question which is not clear to me ......
which collection class offers constant time performance for basic operations -add, remove , contains and size ?
what exactly do they want to mean by "constant time performance" here ?
do they mean , all the above methods will take same amount of execution time ?
BTW , HashSet is the answer .
It means the performance of those methods is O(1). No matter how big the collection gets, the amount of time to do one of those operations remains more or less the same. But no, it doesn't mean those operations all take the same amount of time as each other.
http://en.wikipedia.org/wiki/Big_O_notation
> which collection class offers constant time
> performance for basic operations -add, remove ,
> contains and size ?
I have always thought of these questions as a bit funny. I think that it might get people to write some bad code if they don't understand how the structures work. I can easily implement a class which basically makes a HashSet behave as a List when instances are added to the HashSet.
That is; a bad implementation of hashCode can ruin the performance.
Kaj