Friday, 13 September 2013

Is there a safe way to make a HashSet without manually wrapping it in another object?

Is there a safe way to make a HashSet without manually wrapping it in
another object?

I have recently been having problems with Java apparently swallowing
entire int[] which are different from each other in value when I try to
merge two HashSet<int[]> using the addAll method. I do not have a small
working example because I only observe this behavior in a large dataset of
a million.
My understanding is that the equals and hashCode methods of the int[] are
not implemented to respect either the content or the pointer value of the
reference to an int array. Is there a way to modify the HashSet or the
int[] short of wrapping it, to make it safe to work with HashSet<int[]>?

No comments:

Post a Comment