|
From: SourceForge.net <no...@so...> - 2012-08-22 20:03:24
|
Bugs item #3408867, was opened at 2011-09-13 12:20 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=424682&aid=3408867&group_id=39235 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Correctness Group: Next Minor Release Status: Pending Resolution: None Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Rob Eden (robeden) Summary: TCustomHashMap equals ClassCastException Initial Comment: The following code is a minimal test case that illustrates the problem. ----- package com.jt.jtp; import gnu.trove.map.hash.TCustomHashMap; import gnu.trove.strategy.HashingStrategy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; public class TroveBug { private static byte[] random(int n, Random rnd) { byte[] ba = new byte[n]; for (int i = 0; i < ba.length; i++) { ba[i] = (byte)rnd.nextInt(); } return ba; } private static class ByteArrayStrategy implements HashingStrategy<byte[]> { // Copied from Arrays.hashCode, but applied only to the first four bytes @Override public int computeHashCode(byte[] bytes) { if (bytes == null) return 0; int h = 1; for (int i = 0; i < 4; i++) h = 31 * h + bytes[i]; return h; } @Override public boolean equals(byte[] o1, byte[] o2) { return Arrays.equals(o1, o2); } } public static void main(String[] args) { Random rnd = new Random(1234); TCustomHashMap<byte[], Integer> map = new TCustomHashMap<byte[], Integer>(new ByteArrayStrategy()); List<byte[]> list = new ArrayList<byte[]>(); for (int i = 0; i < 1000; i++) { byte[] ba = random(16, rnd); list.add(ba); map.put(ba, new Integer(i)); } for (int i = 0; i < 1000; i++) { map.remove(list.get(i)); } // Print all nulls! for (int i = 0; i < 1000; i++) { System.out.println(map.get(list.get(i))); } } } ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2012-08-22 13:03 Message: Hi! Do you know if they make any plugins to help with Search Engine Optimization? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good success. If you know of any please share. Kudos! http://www.goodwinterjacketsforwomen.us/ ---------------------------------------------------------------------- Comment By: Rob Eden (robeden) Date: 2011-10-06 21:44 Message: This bug is being put into "pending" status. It will automatically be closed in 14 days in no further action is taken. Please make a comment if you believe the bug to still be relevant. ---------------------------------------------------------------------- Comment By: Rob Eden (robeden) Date: 2011-10-06 21:44 Message: I guess I don't see the bug. It should print nulls at the end because the elements are being removed from the map in the for loop prior to the println's. I've added the test TCusomtHashMap.testBug4706479() to test all my expectations for this case. ---------------------------------------------------------------------- Comment By: Rob Eden (robeden) Date: 2011-09-13 12:21 Message: Looking into this... Associated forum topic: https://sourceforge.net/projects/trove4j/forums/forum/121845/topic/4706479 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=424682&aid=3408867&group_id=39235 |