/// <summary> /// Add element into Linked List /// </summary> /// <param name="data">Node data</param> public void Add(T data) { if (data == null) { throw new ArgumentNullException(); } BiNode <T> node = new BiNode <T>(data); if (count == 0) { head = node; } else { node.Previous = tail; tail.Next = node; } tail = node; count++; }
/// <summary> /// Add element into head of Linked List /// </summary> /// <param name="data">Node data</param> public void AppendFirst(T data) { if (data == null) { throw new ArgumentNullException(); } var node = new BiNode <T>(data); if (count == 0) { head = node; tail = head; } else { node.Next = head; head = node; } count++; }
/// <summary> /// Removes all data from the Linked List /// </summary> public void Clear() { head = null; tail = null; count = 0; }