Permalink
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...
alanmcgovern committed Aug 18, 2011
2 parents 1fe0e5f + e787a12 commit d23d8aa18ae871a301b5b98b36e942005a3ec69f
@@ -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)
@@ -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 d23d8aa

Please sign in to comment.