Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public DoublyLinkedListNode(T item, DoublyLinkedListNode<T> next = null, DoublyLinkedListNode<T> prev = null)
- {
- Item = item;
- Next = next;
- Prev = prev;
- }
- }
- #region Properties_DDL
- /// <summary>
- /// Reference to the "front" of the list
- /// </summary>
- private DoublyLinkedListNode Head { get; set; }
- /// <summary>
- /// Reference to the "end" of the list
- /// </summary>
- private DoublyLinkedListNode Tail { get; set; }
- /// <summary>
- /// Number of items in the list
- /// </summary>
- public int Count { get; private set; }
- #endregion
- /// <summary>
- /// Add the item to the front of the list
- /// </summary>
- /// <param name="item">item to add</param>
- public void AddFront(int item)
- {
- //Adding to Empty List in Front
- if (this.head == null)
- {
- this.head = new DoublyLinkedListNode<U>(item);
- this.tail = this.head;
- }
- //Adding Item to Current List Front
- else
- {
- head.Prev = new DoublyLinkedListNode<U>(item);
- head.Prev.Next = head;
- head = head.Prev;
- }
- count++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement