Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit f105c6d4e7e59cc452564c8b33bdd7a20d3754e9 1 parent 2e637c4
@alanmcgovern alanmcgovern authored
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]
Please sign in to comment.
Something went wrong with that request. Please try again.