@@ 187-204 (lines=18) @@ | ||
184 | * |
|
185 | * @since 1.0.0 |
|
186 | */ |
|
187 | public function predecessor() |
|
188 | { |
|
189 | if ($this->information & 2) |
|
190 | { |
|
191 | $node = $this->left; |
|
192 | ||
193 | while ($node->information & 1) |
|
194 | { |
|
195 | $node = $node->right; |
|
196 | } |
|
197 | ||
198 | return $node; |
|
199 | } |
|
200 | else |
|
201 | { |
|
202 | return $this->left; |
|
203 | } |
|
204 | } |
|
205 | ||
206 | /** |
|
207 | * Get the successor |
|
@@ 213-230 (lines=18) @@ | ||
210 | * |
|
211 | * @since 1.0.0 |
|
212 | */ |
|
213 | public function successor() |
|
214 | { |
|
215 | if ($this->information & 1) |
|
216 | { |
|
217 | $node = $this->right; |
|
218 | ||
219 | while ($node->information & 2) |
|
220 | { |
|
221 | $node = $node->left; |
|
222 | } |
|
223 | ||
224 | return $node; |
|
225 | } |
|
226 | else |
|
227 | { |
|
228 | return $this->right; |
|
229 | } |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Count the number of key/value pair |