public void print() { QueueClassNode runner = head; while (runner != null) { Console.Write("| " + runner.data + " |\n"); runner = runner.next; } Console.Write("\n"); }
public dynamic dequeue() { QueueClassNode temp = head; if (count != 0) { head = head.next; count--; Console.WriteLine(temp.data + " dequeued"); return(temp.data); } else { return(null); } /*while (runner != null && index == count) * { * Console.WriteLine("Dequeded Value is ",runner.data); * front = runner.next; * return; * } * * while (runner != null && index != count) * { * index++; * prev = runner; * runner = runner.next; * } * * if (runner == null) * { * count++; * return; * } * * front = prev; * prev.next = runner.next; */ }
public void enqueue(int data) { Console.Write("inserted value " + data + "\n"); QueueClassNode node = new QueueClassNode(data); if (count == 0) { head = rear = node; } else { rear.next = node; rear = rear.next; } count++; }
public void reverse() { QueueClassNode runner = head, prev = null, next = null; if (runner == null) { return; } while (runner != null) { next = runner.next; runner.next = prev; prev = runner; runner = next; } head = prev; }
public QueueClassNode(int value) { data = value; next = null; }
public Queue() { front = null; this.count = 0; }