<?php
class Queue
{
/******************************************************************************************************************
-Used to initialise variables.
/******************************************************************************************************************/
var
$arrQueue, // Array of queue items
$intBegin, // Begin of queue - head
$intEnd, // End of queue - tail
$intCurrentSize; // Current size of array
/******************************************************************************************************************
-Class constructor.
/******************************************************************************************************************/
function Queue()
{
$this->arrQueue=array();
$this->Clear();
}
/******************************************************************************************************************
-Used to get the current size of the queue.
/******************************************************************************************************************/
function GetCurrentSize()
{
return $this->intCurrentSize;
}
/******************************************************************************************************************
-Used to add an item to the queue.
/******************************************************************************************************************/
function Put(&$objQueueItem)
{
$this->arrQueue[$this->intEnd] = $objQueueItem;
$this->intCurrentSize++;
$this->intEnd++;
return true;
}
/******************************************************************************************************************
-Used to retrive an item from the queue.
/******************************************************************************************************************/
function Get()
{
if($this->IsEmpty())return false;
$objItem = $this->arrQueue[$this->intBegin];
$this->intBegin++;
$this->intCurrentSize--;
return $objItem;
}
/******************************************************************************************************************
-Used to determine if the queue is empty or not.
/******************************************************************************************************************/
function IsEmpty()
{
return ( $this->intCurrentSize == 0 ? true : false );
}
/******************************************************************************************************************
-Used to clear the queue.
/******************************************************************************************************************/
function Clear()
{
$this->arrCurrentSize = 0;
$this->intBegin = 0;
$this->intEnd = 0;
}
}
?>