Browse files

Merge pull request #161 from LogosBible/master

Fix bug #311: On LinkedList.Clear, detach each node instead of dropping them en masse.
  • Loading branch information...
1 parent 2e637c4 commit f105c6d4e7e59cc452564c8b33bdd7a20d3754e9 @alanmcgovern alanmcgovern committed Aug 18, 2011
View
5 mcs/class/System/System.Collections.Generic/LinkedList.cs
@@ -182,9 +182,8 @@ public void AddLast (LinkedListNode <T> node)
public void Clear ()
{
- count = 0;
- first = null;
- version++;
+ while (first != null)
+ RemoveLast();
}
public bool Contains (T value)
View
5 mcs/class/System/Test/System.Collections.Generic/LinkedListTest.cs
@@ -84,8 +84,13 @@ public void NonCircularNodeTest ()
[Test]
public void ClearTest ()
{
+ LinkedListNode <int> node = intlist.First;
intlist.Clear ();
+
Assert.AreEqual (0, intlist.Count);
+ Assert.AreEqual (2, node.Value);
+ Assert.IsNull (node.Next);
+ Assert.IsNull (node.Previous);
}
[Test]

0 comments on commit f105c6d

Please sign in to comment.