Location: PHPKode > scripts > Polymorphic Queue > polymorphic-queue/queue.php
<?php
class queue
{	var $fin=0;
	var $ini=0;
	var $els=array();
	function top() {if ($this->ini==$this->fin) return; $aux=$this->els[$this->ini]; return $aux;}
	function push($x) {$this->els[$this->fin]=$x; $this->fin++;}
	function pop() {if ($this->ini==$this->fin) return; $aux=$this->els[$this->ini]; unset($els[$this->ini]); $this->ini++; return $aux;}
	function count() {return (($this->fin)-($this->ini));}
	function debug() //muestra los elementos en el orden en que se guardan en memoria
	{printf("<hr>CONT=%d<br>",$this->count()); for($i=$this->ini; $i<$this->fin; $i++) echo $this->els[$i].","; echo"<hr>";}
	function show() //muestra los elementos en el orden en que se sacarĂ¡n (en la cola == que se meten (debug)
	{$this->debug();}
	function kill() {$this->els=array(); $this->ini=0; $this->fin=0;}
	function isempty() {return ($this->ini==$this->fin);}
	function isnotempty() {return (!$this->isempty());}
}
?>
Return current item: Polymorphic Queue