| 1 | <?php |
||
| 7 | abstract class ListAbstract implements ListInterface { |
||
| 8 | protected $size; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Binds to count() method. This is equal to make $this->tree->size(). |
||
| 12 | * |
||
| 13 | * @return integer the tree size. 0 if it is empty. |
||
| 14 | */ |
||
| 15 | public function count() { |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Returns the array size. |
||
| 21 | * |
||
| 22 | * @return int the length |
||
| 23 | */ |
||
| 24 | public function size() : int { |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Checks if the list is empty. |
||
| 30 | * |
||
| 31 | * @return boolean true if is empty, else false. |
||
| 32 | */ |
||
| 33 | public function empty() : bool { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Adds at the end of the list new node containing |
||
| 39 | * the data to be stored. |
||
| 40 | * |
||
| 41 | * @param mixed $data The data |
||
| 42 | */ |
||
| 43 | public function push($data) { |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Adds at the beginning a node in the list. |
||
| 49 | * |
||
| 50 | * @param mixed $data |
||
| 51 | * @return mixed the data stored. |
||
| 52 | */ |
||
| 53 | public function unshift($data) { |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Deletes the first node of the list and returns it. |
||
| 59 | * |
||
| 60 | * @return mixed the data. |
||
| 61 | */ |
||
| 62 | public function shift() { |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Removes and returns the last node in the list. |
||
| 68 | * |
||
| 69 | * @return mixed data in node. |
||
| 70 | */ |
||
| 71 | public function pop() { |
||
| 74 | } |