public T DeQueue() { var temp = Front; Front = Front.Next; if (this.Front == null) { this.Rear = null; } return(temp.Data); }
public string printList() { NodeSingly <T> n = Head; string result = ""; while (n != null) { result += n.Data.ToString() + "->"; n = n.Next; } return(result); }
public void EnQueue(T data) { var newData = new NodeSingly <T>(data); if (Front == null && Rear == null) { Front = newData; Rear = newData; return; } Rear.Next = newData; Rear = newData; }
public void Append(NodeSingly <T> NodeSingly) { if (Head == null) { Head = NodeSingly; return; } var temp = Head; while (temp.Next != null) { temp = temp.Next; } temp.Next = NodeSingly; }
public void deleteNodeSingly(int position) { // If linked list is empty if (Head == null) { return; } // Store head NodeSingly NodeSingly <T> temp = Head; // If head needs to be removed if (position == 0) { // Change head Head = temp.Next; return; } // Find previous NodeSingly of the NodeSingly to be deleted for (int i = 0; temp != null && i < position - 1; i++) { temp = temp.Next; } // If position is more than number of NodeSinglys if (temp == null || temp.Next == null) { return; } // NodeSingly temp->next is the NodeSingly to be deleted // Store pointer to the next of NodeSingly to be deleted NodeSingly <T> next = temp.Next.Next; // Unlink the deleted NodeSingly from list temp.Next = next; }
public void Push(NodeSingly <T> NodeSingly) { NodeSingly.Next = this.Head; this.Head = NodeSingly; }
public LinkedListSingly(NodeSingly <T> head) { Head = head; }
public NodeSingly(T data, NodeSingly <T> next = null) { Data = data; Next = next; }