Stack.php
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class IRP_Stack { |
| 5 | var $array; |
| 6 | |
| 7 | public function __construct() { |
| 8 | $this->array=array(); |
| 9 | } |
| 10 | |
| 11 | public function push($v) { |
| 12 | array_push($this->array, $v); |
| 13 | } |
| 14 | public function pop() { |
| 15 | $v=array_pop($this->array); |
| 16 | return $v; |
| 17 | } |
| 18 | public function peek() { |
| 19 | return $this->array[count($this->array)-1]; |
| 20 | } |
| 21 | public function size() { |
| 22 | return count($this->array); |
| 23 | } |
| 24 | public function isEmpty() { |
| 25 | return (count($this->array)==0); |
| 26 | } |
| 27 | } |
| 28 |