static void Main(string[] args) { Console.WriteLine("\nBuild queue to challenge example."); PseudoQ<int> qu = new PseudoQ<int>(); qu.Enqueue(20); qu.Enqueue(15); qu.Enqueue(10); qu.Print(); Console.ReadLine(); Console.Write("Adding 5 to the rear of the queue: "); qu.Enqueue(5); qu.Print(); Console.ReadLine(); qu.Dequeue(); qu.Dequeue(); qu.Dequeue(); qu.Dequeue(); Console.WriteLine("\nQueue reset."); qu.Enqueue(20); qu.Enqueue(15); qu.Enqueue(10); qu.Enqueue(5); qu.Print(); Console.ReadLine(); Console.Write($"Removed: {qu.Dequeue().Value}; New queue: "); qu.Print(); Console.ReadLine(); }
public void Enqueue_PointsNewRearAtPriorRear() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); Assert.Equal(3, qu.Frontend.Top.Next.Value); }
public void Enqueue_AddsNewRear() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); Assert.Equal(1, qu.Frontend.Top.Value); }
public void Dequeue_ReassignsFrontendTop() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); qu.Dequeue(); Assert.Equal(3, qu.Backend.Top.Value); }
public void Offload_ExposesBottomOfFromStack() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); qu.Offload(qu.Frontend, qu.Backend); Assert.Equal(5, qu.Backend.Top.Value); }
public void Offload_EmptiesFromStack() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); qu.Offload(qu.Frontend, qu.Backend); Assert.Null(qu.Frontend.Top); }
public void Dequeue_ReturnsFrontNode() { PseudoQ <int> qu = new PseudoQ <int>(); qu.Enqueue(5); qu.Enqueue(3); qu.Enqueue(1); Node <int> removed = qu.Dequeue(); Assert.Equal(5, removed.Value); }
public void PseudoQ_BuildsBackendStack() { PseudoQ <int> qu = new PseudoQ <int>(); Assert.Null(qu.Backend.Top); }
public void PseudoQ_ConstructsNewPseudoqueueWithNullRear() { PseudoQ <int> qu = new PseudoQ <int>(); Assert.Null(qu.Rear); }
public void PseudoQ_ConstructsNewPseudoqueueWithNullFront() { PseudoQ <int> qu = new PseudoQ <int>(); Assert.Null(qu.Front); }