CSharpTest.Net
LListNode<T> Constructor()
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LListNode<T> Class > LListNode<T> Constructor : LListNode<T> Constructor()

Glossary Item Box

Constructs a node without a value

Syntax

Visual Basic (Declaration) 
Public Function New()
C# 
public LListNode<T>()

Example

Library/Library.Test/TestLinkList.cs

C#Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NETCopy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys