Skip to content

Commit

Permalink
Merge pull request #161 from LogosBible/master
Browse files Browse the repository at this point in the history
Fix bug #311: On LinkedList.Clear, detach each node instead of dropping them en masse.
  • Loading branch information
alanmcgovern committed Aug 18, 2011
2 parents 1fe0e5f + e787a12 commit d23d8aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mcs/class/System/System.Collections.Generic/LinkedList.cs
Expand Up @@ -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)
Expand Down
Expand Up @@ -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]
Expand Down

0 comments on commit d23d8aa

Please sign in to comment.