1 | <?php |
||
23 | class ArrayList extends ListAbstract { |
||
24 | use ArrayAccessTrait; |
||
25 | |||
26 | private $data; |
||
27 | private $current; |
||
28 | private $position; |
||
29 | |||
30 | public function __construct() { |
||
35 | |||
36 | /** |
||
37 | * Add a new node in the specified index. |
||
38 | * |
||
39 | * @param integer $index the position. |
||
40 | * @param mixed $data the data to be stored. |
||
41 | */ |
||
42 | public function insert($index, $data) { |
||
46 | |||
47 | protected function insertAt($index, $data) {} |
||
48 | |||
49 | protected function insertEnd($data) {} |
||
50 | |||
51 | protected function insertBeginning($data) {} |
||
52 | |||
53 | /** |
||
54 | * Removes all the array items. |
||
55 | */ |
||
56 | public function clear() { |
||
60 | |||
61 | /** |
||
62 | * Returns the array in the especified index. |
||
63 | * |
||
64 | * @param integer $index Index that must be greater than 0 |
||
65 | * and lower than the list size. |
||
66 | * @return mixed The data stored in the given index |
||
67 | * @throws OutOfBoundsException if index is out bounds. |
||
68 | */ |
||
69 | public function get($index) { |
||
76 | |||
77 | /** |
||
78 | * Returns the last node with O(1). |
||
79 | * |
||
80 | * @return mixed null if the array is empty. |
||
81 | */ |
||
82 | public function getLast() { |
||
89 | |||
90 | public function getAll() { |
||
95 | |||
96 | /** |
||
97 | * {@inheritDoc} |
||
98 | */ |
||
99 | public function contains($data) : bool { |
||
102 | |||
103 | /** |
||
104 | * {@inheritDoc} |
||
105 | */ |
||
106 | public function indexOf($data) { |
||
109 | |||
110 | /** |
||
111 | * {@inheritDoc} |
||
112 | */ |
||
113 | public function lastIndexOf($data) { |
||
122 | |||
123 | /** |
||
124 | * {@inheritDoc} |
||
125 | */ |
||
126 | public function remove($data) { |
||
140 | |||
141 | /** |
||
142 | * Delete a node in the given position and returns it back. |
||
143 | * |
||
144 | * @param integer $index the position. |
||
145 | * @throws OutOfBoundsException if index is negative |
||
146 | * or is greater than the size of the list. |
||
147 | */ |
||
148 | public function delete($index) { |
||
159 | |||
160 | /** |
||
161 | * Returns array stored in the data attribute. |
||
162 | * |
||
163 | * @return array data stored in all nodes. |
||
164 | */ |
||
165 | public function toArray() : array { |
||
168 | |||
169 | /** |
||
170 | * Reset the cursor position. |
||
171 | */ |
||
172 | public function rewind() { |
||
176 | |||
177 | /** |
||
178 | * Returns the current node data. |
||
179 | * |
||
180 | * @return mixed |
||
181 | */ |
||
182 | public function current() { |
||
185 | |||
186 | /** |
||
187 | * Key or index that indicates the cursor position. |
||
188 | * |
||
189 | * @return integer The current position. |
||
190 | */ |
||
191 | public function key() { |
||
194 | |||
195 | /** |
||
196 | * Move the cursor to the next node and increments the |
||
197 | * position counter. |
||
198 | */ |
||
199 | public function next() { |
||
203 | |||
204 | /** |
||
205 | * Returns if the current pointer position is valid. |
||
206 | * |
||
207 | * @return boolean true if pointer is not last, else false. |
||
208 | */ |
||
209 | public function valid() { |
||
212 | } |