/// <summary> /// The Method to add a new node. /// </summary> /// <param name="value">The value to be stored in the node.</param> public void AddNode(int value) { if (this.Value < value) { if (this.Next == null) { this.Next = new SingleNodeList(value); } else { this.Next.AddNode(value); } } else { SingleNodeList temp = new SingleNodeList(this.Value, this.Next); this.Value = value; this.Next = temp; } }
/// <summary> /// Initializes a new instance of the <see cref="SingleNodeList" /> class. /// Used for moving the next node to a new /// </summary> /// <param name="value">The value to be stored.</param> /// <param name="next">The Next node to be moved </param> private SingleNodeList(int value, SingleNodeList next) { this.Value = value; this.Next = next; }