class test
{
private $queue = array();《头部入队》
public function addfirst($value)
{
return array_unshift($this->queue,$value);
}
《尾部入队》
public function addlast($value)
{
return array_push($this->queue,$value);
}
《头部出队》
public function removefirst()
{
return array_shift($this->queue);
}
《尾部出队》
public function removelast()
{
return array_pop($this->queue);
}
《显示》
public function show()
{
echo implode(",",$this->queue);
}
}
本文介绍了一个简单的PHP队列类实现,包括头部和尾部的入队与出队操作,并展示了如何通过内置函数来实现这些功能。
513

被折叠的 条评论
为什么被折叠?



