return true; } else { return false; } } public function isFull() { } } $q = new Queue(5); // instantiates the Queue class with a maxSize attribute of 5 $q->isEmpty(); // returns true $q->enqueue(100); // Queue: 100 $q->rear(); // returns 100 $q->front(); // returns 100 $q->enqueue(20); // Queue: 100, 20 $q->enqueue(2); // Queue: 100, 20, 2 $q->dequeue(); // Queue: 20, 2 $q->enqueue(500); // Queue: 20, 2, 500 $q->enqueue(12); // Queue: 20, 2, 500, 12 $q->enqueue(30); // Queue: 20, 2, 500, 12, 30
echo "Queue: "; $current = $this->front; while ($current) { echo $current->value . ", "; $current = $current->next; } echo "<br>"; } } $q = new Queue(5); // instantiates the Queue class with a maxSize attribute of 5 echo $q->isEmpty() . "<br>"; // returns true $q->enqueue(100); // Queue: 100 echo $q->rear() . "<br>"; // returns 100 echo $q->front() . "<br>"; // returns 100 $q->enqueue(20); // Queue: 100, 20 $q->enqueue(2); // Queue: 100, 20, 2 $q->dequeue(); // Queue: 20, 2 $q->enqueue(500); // Queue: 20, 2, 500 $q->enqueue(12); // Queue: 20, 2, 500, 12 $q->enqueue(30); // Queue: 20, 2, 500, 12, 30