手记

队列php实现

<?php

class QueueClass

{

private $queue=null;

private $fornt=0;

private $tail=0;

public function __construct()

{

$this->fornt=0;

$this->tail=0;

$this->queue=array();

}

public function add_item($item)

{

$this->queue[$this->tail++]=$item;

}

public function del_item()

{

if(!$this->is_empty())

{

$del=$this->queue[$this->fornt];

unset($this->queue[$this->fornt++]);

return $del;

}

}

public function is_empty()

{

if($this->fornt===$this->tail)

{

return true;

}

}

public function get_queue()

{

return $this->queue;

}

public function get_length()

{

return count($this->queue);

}

}

?>


0人推荐
随时随地看视频
慕课网APP