-
The Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE by definition.
Here, the %11 return -2, thus the AIOOBE.
IntSet s = new IntChainedHashSet();
System.out.println(Math.abs(Long.MIN_VALUE));
System.out.println(Math.abs(Integer.MIN_VALUE));
s.add(Integer.MIN_VALUE); //ArrayIndexOutOfBoundsException !!!!!
2009-03-26 15:36:31 UTC by nobody
-
This simple code show the IntChainedHashSet.clear(), LongChainedHashSet.clear() (etc) are not implemented correctly:
IntSet s = new IntChainedHashSet();
s.add(33);
s.clear();
System.out.println(s); //WTF???!!
System.out.println(s.iterator().hasNext());//WTF???!!
boolean b = s.add(33);
System.out.println(b); //WTF???!!
2009-03-26 15:24:53 UTC by nobody
-
RangeSet normalization fails as pointed out in the tracker item 1499302 (https://sourceforge.net/tracker/index.php?func=detail&aid=1499302&group_id=69499&atid=524737). Please note that the patch suggested by neil_bacon does not work.
2008-05-11 13:23:17 UTC by bak
-
The optimization for OpenHashSets that tries to reuse slots by marking them removed causes them to not behave correctly and could like lead to memory leaks over time.
Consider this example using only 2 values that happen to have the same hash value:
LongHashFunction hash = DefaultLongHashFunction.INSTANCE;
LongOpenHashSet set = new LongOpenHashSet( hash );
long value1 =...
2007-01-05 04:48:58 UTC by daleking
-
I was looking at the LongOpenHashSet code and saw that in the implementation you have an array that has the values and a byte array to hold the status of each item. This byte array could easily be eliminated reducing the memory usage by 11% for LongOpenHashSet, 20% for IntOpenHashSet, and 33% for CharOpenHashSet and ShortOpenHashSet.
A cell can have one of three state empty, removed, or...
2007-01-05 03:57:01 UTC by daleking
-
The map constructors are calling
expandAt = (int)Math.round(loadFactor*capacity);
(a simple cast from double to int would suffice)
expandAt = (int)(loadFactor*capacity);
Turns out that Math.round calls eventually
StrictMath.floor which is a native method.
When you create thousands of maps per seconds, that
adds up enough to show on a jvm profiler.
2006-09-21 13:16:02 UTC by nobody
-
The following will produce an
ArrayIndexOutOfBoundsException:
LongKeyOpenHashMap m2 = new LongKeyOpenHashMap(64);
m2.get(2147483648L);
It's because Math.abs() can return a negative number,
when the input is Integer.MIN_VALUE.
When the input of get is 2147483648L, the following
operations will be performed:
1- hash using DefaultLongHashFunction (v = 2147483648L)
return (int)(v ^...
2006-08-21 15:25:48 UTC by dan666