<?
class Queue
{
 var $dataLine = array();
 var $size     = 5; //定义队列长度

 function Queue($size=0)
 {
  if($size != 0) $this->size = $size;
 }

    //Desc:元素入队
 function enQueue($data)
 {
  if(count($this->dataLine) == $this->size) return ;
  $this->dataLine[count($this->dataLine)] = $data;
 }

    //Desc:元素出队
 function deQueue()
 {
  $data = $this->dataLine[count($this->dataLine)-1];
  unset($this->dataLine[count($this->dataLine)-1]);
  
  return $data;
 }

    //Desc:队列元素个数统计
 function countQueue()
 {
  return count($this->dataLine);
 }

    //Desc:清空队列中的元素
 function clearQueue()
 {
  $this->dataLine = array();
 }
}
?>

posted on 2007-01-06 12:09  成都发哥  阅读(386)  评论(1)    收藏  举报