php
class Stack
{
private $stack;
public function __construct()
{
$this->stack = array();
}
public function push($item)
{
array_push($this->stack, $item);
}
public function pop()
{
if (!$this->isEmpty()) {
return array_pop($this->stack);
}
return null;
}
public function isEmpty()
{
return empty($this->stack);
}
public function top()
{
return end($this->stack);
}
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-