static void Main(string[] args) { MyQueue <int> myQueue = new MyQueue <int>(); Node <int> e1 = new Node <int>(1); myQueue.Enqueue(e1); Node <int> e2 = new Node <int>(2); myQueue.Enqueue(e2); Node <int> e3 = new Node <int>(3); myQueue.Enqueue(e3); //print queue Console.WriteLine("myQueue: " + string.Join(" ", myQueue.GetQ())); //dequeue int retVal = myQueue.Dequeue(); Console.WriteLine("Dequeued value: " + retVal); //print queue again Console.WriteLine("myQueue: " + string.Join(" ", myQueue.GetQ())); //search - false Console.WriteLine(myQueue.Search(e1.value)); //search - true Console.WriteLine(myQueue.Search(e2.value)); Console.ReadLine(); }
static void Main(string[] args) { MyQueue <int> queue = new MyQueue <int>(); queue.Enqueue(1); queue.Enqueue(2); Console.WriteLine(queue.Dequeue()); Console.WriteLine(queue.Dequeue()); }
public static void Main() { var queue = new MyQueue <int>(1); queue.Enqueue(3); queue.Enqueue(5); queue.Enqueue(4); Console.WriteLine(queue.Peek()); Console.WriteLine(queue.Dequeue()); Console.WriteLine(queue.Dequeue()); }
static void Main(string[] args) { // Declare and populate the nodes Node node = new Node() { Value = 4 }; Node node2 = new Node() { Value = 8 }; Node node3 = new Node() { Value = 15 }; Node node4 = new Node() { Value = 16 }; Node node5 = new Node() { Value = 23 }; Node node6 = new Node() { Value = 42, Next = null }; // Point last item on queue to null. Necessary for passing unit tests. Node node7 = new Node(); // Instatiate the queue MyQueue queue = new MyQueue(node); // Populate the queue queue.Enqueue(node2); queue.Enqueue(node3); queue.Enqueue(node4); queue.Enqueue(node5); queue.Enqueue(node6); queue.PrintAllNodes(); // Print the queue before the dequeue node7 = queue.Dequeue(); Console.WriteLine($"Dequed {node7.Value}"); queue.PrintAllNodes(); // Print the queue after the dequeue Console.ReadLine(); }
static void Main(string[] args) { var myQueue = new MyQueue <int>(); myQueue.Enqueue(1); myQueue.Enqueue(2); myQueue.Enqueue(3); myQueue.Enqueue(4); myQueue.Enqueue(5); Console.WriteLine(myQueue.Dequeue()); Console.WriteLine(myQueue.Peek()); Console.WriteLine(myQueue.Dequeue()); Console.ReadLine(); }
static void Main() { MyQueue <int> numbers = new MyQueue <int>(); for (int i = 1; i < 5; i++) { numbers.Enqueue(i); } int firstElement = numbers.Peek(); Console.WriteLine(firstElement); // There is some bug with the dequeue that i need to find //numbers.Dequeue(); try { foreach (var number in numbers) { Console.WriteLine(number); } } catch (Exception e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { var myQueue = new MyQueue <int>(); myQueue.Enqueue(1); myQueue.Enqueue(2); myQueue.Enqueue(3); myQueue.Enqueue(4); foreach (int i in myQueue.ToArray()) { Console.WriteLine(i); } Console.WriteLine(); while (myQueue.Count > 0) { Console.WriteLine(myQueue.Dequeue()); } Console.ReadKey(); }
static void Main(string[] args) { MyQueue <int> a = new MyQueue <int>(); a.Enqueue(2); a.Enqueue(3); a.Enqueue(4); a.Enqueue(5); a.Enqueue(6); a.Enqueue(7); a.Enqueue(8); a.Dequeue(); a.Dequeue(); a.Dequeue(); }