示例#1
0
文件: index.php 项目: sourabhpal/PHP
            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
$q->isFull();
// returns true
示例#2
0
        }
        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
echo $q->isFull() . "<br>";
// returns true
echo "<h3> Trying to enqueue over limit</h3>";
//try to push on more than limit
$q->enqueue(69);