Supraja Jayakumar wrote:A small correction to the question: I want to set an upperlimit on the size of the hashmap.
Then strictly speaking I suspect you don't want to set an upper limit on the size of the HashMap; you want to set an upper limit on the number of buckets. And don't forget that HashMap actually applies a second hash to yours when it determines the bucket to put it in.
I have a feeling you might be better off using a TreeMap<Integer, Object> (or maybe a ConcurrentSkipListMap; it may be smaller) and simply adding objects and their hashcodes, and logging the times when your put() returns a non-null value. However, if your hash function is good, you may need an enormous number of objects before you get a collision. Alternatively, have a look at the HashMap source and duplicate its secondary hash for a particular size of "bucket map".
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com