public void InsertAtHead(object val) { listNode newNode = new listNode(val); newNode.Next = this.head; this.head = newNode; }
public void Push(Object k) { listNode newNode = new listNode(k); newNode.Next = _top; _top = newNode; _size++; }
public void print() { listNode current = this.head; while (current != null) { Console.WriteLine(current.Data); current = current.Next; } }
public listNode remove() { if (_head == null) { _tail = null; throw new Exception("the list is already empty"); } listNode current = _head; _head = _head.Next; size--; updateMin(); return(current); }
public listNode Pop(Object k) { listNode result; if (_top == null) { throw new Exception("Stack is empty"); } result = _top; _top = _top.Next; _size--; return(result); }
private void updateMin() { if (_head == null) { return; } listNode current = _head; while (current.Next != null) { if ((int)minElement < (int)current.Data) { minElement = current.Data; } current = current.Next; } }
public void deleteNode(object val) { listNode current = this.head; if (head != null) { while (current.Next != null) { if (current.Next.Data == val) { current.Next = current.Next.Next; return; } current = current.Next; } } }
public void insertAtEnd(object val) { bool flag = false; if (head == null) { InsertAtHead(val); } else { listNode current = this.head; while (current.Next != null) { current = current.Next; } listNode newNode = new listNode(val); current.Next = newNode; size++; } }
public void queueAdd(object k) { listNode current; if (_tail == null) { current = new listNode(k); _head = _tail = current; minElement = k; size++; } else { listNode newNode = new listNode(k); _tail.Next = newNode; _tail = newNode; if ((int)k < (int)minElement) { minElement = k; } size++; } }
public Queues() { _head = null; _tail = null; size = 0; }
public LinkedList_imp() { head = null; size = 0; }
public Stacks() { _top = null; _size = 0; }