| 
 
/** 
*@php模拟  队列 
*/ 
class Queue 
{ 
 private $myQueue;  //队列容器 
 private $size ;     //队列的长度 
 public function __construct() 
 { 
  $this->myQueue=array(); 
  $this->size=0; 
 } 
 /** 
 *@入栈操作 
 */ 
 public function putQueue($data) 
 { 
  $this->myQueue[$this->size++]=$data; 
  return $this; 
 } 
 /** 
 *@出栈 
 */ 
 public function getQueue() 
 { 
  if(!$this->isEmpty()) 
  { 
                    $front=array_splice($this->myQueue,0,1); 
                    $this->size--; 
      return $front[0]; 
  } 
  return false; 
 } 
 /** 
 *@ 获取全部的消息队列 
 */ 
 public function allQueue() 
 { 
  return $this->myQueue; 
 } 
 /** 
 *@ 获取队列的表态 
 */ 
 public function frontQueue() 
 { 
  if(!$this->isEmpty()) 
  { 
   return $this->myQueue[0]; 
  } 
  return false; 
 } 
 /** 
 *@ 返回队列的长度 
 */ 
 public function getSize() 
 { 
  return $this->size; 
 } 
   public function isEmpty() 
   { 
     return 0===$this->size; 
   } 
} 
?> 
 |