首页 > Web开发 > 详细

用 PHP 实现一个双向队列

时间:2016-03-26 21:48:25      阅读:277      评论:0      收藏:0      [点我收藏+]
class DEQueue {
    //存储
    protected $_storage = array();
    
    //入头
    public function unshift($element)
    {
        return array_unshift($this->_storage, $element);
    }
    
    //入尾
    public function push($element)
    {
        return array_push($this->_storage, $element);
    }
    
    //出尾
    public function pop()
    {
        return array_pop($this->_storage);
    }
    
    //出头
    public function shift()
    {
        return array_shift($this->_storage);
    }
    
    //长度
    public function length()
    {
        return count($this->_storage);
    }
}

 

用 PHP 实现一个双向队列

原文:http://www.cnblogs.com/fyy-888/p/5324021.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!