background image

   */
  public function enqueue($data) {
    $this->queue[$this->size++] = $data;
 
    return $this;
  }
 
  /**
   * 出队操作。
   *
   * @return mixed 空队列时返回 FALSE,否则返回队头元素。
   */
  public function dequeue() {
    if (!$this->isEmpty()) {
      --$this->size;
      $front = array_splice($this->queue, 0, 1);
 
      return $front[0];
    }
 
    return FALSE;
  }
 
  /**
   * 获取队列。
   *
   * @return array 返回整个队列。
   */
  public function getQueue() {
    return $this->queue;
  }
 
  /**
   * 获取队头元素。
   *
   * @return mixed 空队列时返回 FALSE,否则返回队头元素。
   */
  public function getFront() {
    if (!$this->isEmpty()) {
      return $this->queue[0];
    }
 
    return FALSE;
  }