Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1.             public DoublyLinkedListNode(T item, DoublyLinkedListNode<T> next = null, DoublyLinkedListNode<T> prev = null)
  2.             {
  3.                 Item = item;
  4.                 Next = next;
  5.                 Prev = prev;
  6.             }
  7.         }
  8.  
  9.         #region Properties_DDL
  10.         /// <summary>
  11.         /// Reference to the "front" of the list
  12.         /// </summary>
  13.         private DoublyLinkedListNode Head { get; set; }
  14.  
  15.         /// <summary>
  16.         /// Reference to the "end" of the list
  17.         /// </summary>
  18.         private DoublyLinkedListNode Tail { get; set; }
  19.  
  20.         /// <summary>
  21.         /// Number of items in the list
  22.         /// </summary>
  23.         public int Count { get; private set; }
  24.         #endregion
  25.  
  26.         /// <summary>
  27.         /// Add the item to the front of the list
  28.         /// </summary>
  29.         /// <param name="item">item to add</param>
  30.         public void AddFront(int item)
  31.         {
  32.             //Adding to Empty List in Front
  33.             if (this.head == null)
  34.             {
  35.                 this.head = new DoublyLinkedListNode<U>(item);
  36.                 this.tail = this.head;
  37.             }
  38.             //Adding Item to Current List Front
  39.             else
  40.             {
  41.                 head.Prev = new DoublyLinkedListNode<U>(item);
  42.                 head.Prev.Next = head;
  43.                 head = head.Prev;
  44.             }
  45.             count++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement