PHP Class ArrayQueue (2)
| From: | Antonio Bologna | Date: | Thu, 16 Oct 2003 11:35:05 +0000 |
| Subject: | PHP Class ArrayQueue (2) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166297@lists.php.net to get a copy of this message | ||
Sorry, here it is the code:
<?php
/* Trying to use queues in PHP, let
* see if that works.
*/
class ArrayQueue {
var $theArray = array();
var $currentSize;
var $front;
var $back;
var $DEFAULT_CAPACITY = 10;
function increment($x) {
if(++$x == $theArray.length)
$x = 0;
return $x;
}
function ArrayQueue() {
$theArray = ($DEFAULT_CAPACITY);
ArrayQueue::makeEmpty();
}
function isEmpty() {
return $currentSize = 0;
}
function enqueue($Obj) {
if($currentSize == $theArray.length)
ArrayQueue::doubleQueue();
$back = ArrayQueue::increment($back);
$theArray[$back] = $Obj;
$currentSize++;
}
function makeEmpty() {
$currentSize = 0;
$front = 0;
$back = -1;
}
function objReturn() {
return $front;
}
}