用PHP写的这个双向队列应该怎么使用

婷婷同学_
浏览 579回答 1
1回答

红颜莎娜

<?php class&nbsp;Deque{&nbsp; private&nbsp;$queue&nbsp;=&nbsp;array();&nbsp; public&nbsp;function&nbsp;addFirst($item){&nbsp; return&nbsp;array_unshift($this->queue,&nbsp;$item); } public&nbsp;function&nbsp;addLast($item){&nbsp; return&nbsp;array_push($this->queue,&nbsp;$item); } public&nbsp;function&nbsp;removeFirst(){&nbsp; return&nbsp;array_shift($this->queue); } public&nbsp;function&nbsp;removeLast(){&nbsp; return&nbsp;array_pop($this->queue); } }
打开App,查看更多内容
随时随地看视频慕课网APP