+2007-11-06 Jb Evain <jbevain@novell.com>
+
+ * Hashtable.cs: Don't compare user keys against the special removed
+ key. Fix #324761.
+
2007-11-05 Sebastien Pouliot <sebastien@ximian.com>
* Queue.cs: Avoid IndexOutOfRangeException after TrimToSize. Patch by
/// </summary>
protected virtual bool KeyEquals (Object item, Object key)
{
+ if (key == KeyMarker.Removed)
+ return false;
#if NET_2_0
if (equalityComparer != null)
return equalityComparer.Equals (item, key);
+2007-11-06 Jb Evain <jbevain@novell.com>
+
+ * HashtableTest.cs: Add test case for #324761.
+
2007-11-05 Sebastien Pouliot <sebastien@ximian.com>
* QueueTest.cs: Test cases for #321657. Based on the test case
Assert ("GetEnumerator.IsSerializable", ht.GetEnumerator ().GetType ().IsSerializable);\r
Assert ("Synchronized.IsSerializable", Hashtable.Synchronized (ht).GetType ().IsSerializable);\r
}\r
+\r
+ [Test]\r
+ public void TestHashtableWithCustomComparer ()\r
+ {\r
+ // see bug #324761\r
+ IDHashtable dd = new IDHashtable ();\r
+ Random r = new Random (1000);\r
+ for (int n = 0; n < 10000; n++) {\r
+ int v = r.Next (0, 1000);\r
+ dd [v] = v;\r
+ v = r.Next (0, 1000);\r
+ dd.Remove (v);\r
+ }\r
+ }\r
+}\r
+\r
+class IDHashtable : Hashtable {\r
+\r
+ class IDComparer : IComparer {\r
+ public int Compare (object x, object y)\r
+ {\r
+ if ((int) x == (int) y)\r
+ return 0;\r
+ else\r
+ return 1;\r
+ }\r
+ }\r
+\r
+ class IDHashCodeProvider : IHashCodeProvider {\r
+ public int GetHashCode (object o)\r
+ {\r
+ return (int) o;\r
+ }\r
+ }\r
+\r
+ public IDHashtable ()\r
+ : base (new IDHashCodeProvider (),\r
+ new IDComparer ())\r
+ {\r
+ }\r
}\r
\r
[Serializable]\r