@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param mixed $key The node key |
| 74 | 74 | * @param mixed $value The node value |
| 75 | 75 | * |
| 76 | - * @return A new node |
|
| 76 | + * @return TreeNode new node |
|
| 77 | 77 | * |
| 78 | 78 | * @since 1.0.0 |
| 79 | 79 | */ |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * Get the first node |
| 144 | 144 | * |
| 145 | - * @return the first node |
|
| 145 | + * @return TreeNode first node |
|
| 146 | 146 | * |
| 147 | 147 | * @since 1.0.0 |
| 148 | 148 | */ |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * Get the last node |
| 163 | 163 | * |
| 164 | - * @return the last node |
|
| 164 | + * @return TreeNode last node |
|
| 165 | 165 | * |
| 166 | 166 | * @since 1.0.0 |
| 167 | 167 | */ |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | /** |
| 181 | 181 | * Get the predecessor |
| 182 | 182 | * |
| 183 | - * @return the predecessor node |
|
| 183 | + * @return TreeNode predecessor node |
|
| 184 | 184 | * |
| 185 | 185 | * @since 1.0.0 |
| 186 | 186 | */ |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | /** |
| 207 | 207 | * Get the successor |
| 208 | 208 | * |
| 209 | - * @return the successor node |
|
| 209 | + * @return TreeNode successor node |
|
| 210 | 210 | * |
| 211 | 211 | * @since 1.0.0 |
| 212 | 212 | */ |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * +1 for the lowest key greater than or equal to the given key |
| 266 | 266 | * +2 for the lowest key greater than the given key |
| 267 | 267 | * |
| 268 | - * @return mixed The node or null if not found |
|
| 268 | + * @return TreeNode|null The node or null if not found |
|
| 269 | 269 | * |
| 270 | 270 | * @since 1.0.0 |
| 271 | 271 | */ |
@@ -189,8 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return $node; |
| 192 | - } |
|
| 193 | - else |
|
| 192 | + } else |
|
| 194 | 193 | { |
| 195 | 194 | return $this->left; |
| 196 | 195 | } |
@@ -215,8 +214,7 @@ discard block |
||
| 215 | 214 | } |
| 216 | 215 | |
| 217 | 216 | return $node; |
| 218 | - } |
|
| 219 | - else |
|
| 217 | + } else |
|
| 220 | 218 | { |
| 221 | 219 | return $this->right; |
| 222 | 220 | } |
@@ -273,12 +271,10 @@ discard block |
||
| 273 | 271 | if ($cmp < 0 && $node->information & 2) |
| 274 | 272 | { |
| 275 | 273 | $node = $node->left; |
| 276 | - } |
|
| 277 | - elseif ($cmp > 0 && $node->information & 1) |
|
| 274 | + } elseif ($cmp > 0 && $node->information & 1) |
|
| 278 | 275 | { |
| 279 | 276 | $node = $node->right; |
| 280 | - } |
|
| 281 | - else |
|
| 277 | + } else |
|
| 282 | 278 | { |
| 283 | 279 | break; |
| 284 | 280 | } |
@@ -289,42 +285,34 @@ discard block |
||
| 289 | 285 | if ($type < 0) |
| 290 | 286 | { |
| 291 | 287 | return $node->left; |
| 292 | - } |
|
| 293 | - elseif ($type > 0) |
|
| 288 | + } elseif ($type > 0) |
|
| 294 | 289 | { |
| 295 | 290 | return $node; |
| 296 | - } |
|
| 297 | - else |
|
| 291 | + } else |
|
| 298 | 292 | { |
| 299 | 293 | return null; |
| 300 | 294 | } |
| 301 | - } |
|
| 302 | - elseif ($cmp > 0) |
|
| 295 | + } elseif ($cmp > 0) |
|
| 303 | 296 | { |
| 304 | 297 | if ($type < 0) |
| 305 | 298 | { |
| 306 | 299 | return $node; |
| 307 | - } |
|
| 308 | - elseif ($type > 0) |
|
| 300 | + } elseif ($type > 0) |
|
| 309 | 301 | { |
| 310 | 302 | return $node->right; |
| 311 | - } |
|
| 312 | - else |
|
| 303 | + } else |
|
| 313 | 304 | { |
| 314 | 305 | return null; |
| 315 | 306 | } |
| 316 | - } |
|
| 317 | - else |
|
| 307 | + } else |
|
| 318 | 308 | { |
| 319 | 309 | if ($type < -1) |
| 320 | 310 | { |
| 321 | 311 | return $node->predecessor; |
| 322 | - } |
|
| 323 | - elseif ($type > 1) |
|
| 312 | + } elseif ($type > 1) |
|
| 324 | 313 | { |
| 325 | 314 | return $node->successor; |
| 326 | - } |
|
| 327 | - else |
|
| 315 | + } else |
|
| 328 | 316 | { |
| 329 | 317 | return $node; |
| 330 | 318 | } |
@@ -346,8 +334,7 @@ discard block |
||
| 346 | 334 | { |
| 347 | 335 | $this->right = $right->left; |
| 348 | 336 | $right->left = $this; |
| 349 | - } |
|
| 350 | - else |
|
| 337 | + } else |
|
| 351 | 338 | { |
| 352 | 339 | $right->information |= 2; |
| 353 | 340 | $this->information &= ~ 1; |
@@ -385,8 +372,7 @@ discard block |
||
| 385 | 372 | { |
| 386 | 373 | $this->left = $left->right; |
| 387 | 374 | $left->right = $this; |
| 388 | - } |
|
| 389 | - else |
|
| 375 | + } else |
|
| 390 | 376 | { |
| 391 | 377 | $this->information &= ~ 2; |
| 392 | 378 | $left->information |= 1; |
@@ -484,15 +470,13 @@ discard block |
||
| 484 | 470 | { |
| 485 | 471 | $node = $this->decBalance(); |
| 486 | 472 | } |
| 487 | - } |
|
| 488 | - else |
|
| 473 | + } else |
|
| 489 | 474 | { |
| 490 | 475 | $this->left = new static($key, $value, $this->left, $this); |
| 491 | 476 | $this->information |= 2; |
| 492 | 477 | $node = $this->decBalance(); |
| 493 | 478 | } |
| 494 | - } |
|
| 495 | - elseif ($cmp > 0) |
|
| 479 | + } elseif ($cmp > 0) |
|
| 496 | 480 | { |
| 497 | 481 | if ($this->information & 1) |
| 498 | 482 | { |
@@ -503,15 +487,13 @@ discard block |
||
| 503 | 487 | { |
| 504 | 488 | $node = $this->incBalance(); |
| 505 | 489 | } |
| 506 | - } |
|
| 507 | - else |
|
| 490 | + } else |
|
| 508 | 491 | { |
| 509 | 492 | $this->right = new static($key, $value, $this, $this->right); |
| 510 | 493 | $this->information |= 1; |
| 511 | 494 | $node = $this->incBalance(); |
| 512 | 495 | } |
| 513 | - } |
|
| 514 | - else |
|
| 496 | + } else |
|
| 515 | 497 | { |
| 516 | 498 | $this->value = $value; |
| 517 | 499 | } |
@@ -536,13 +518,11 @@ discard block |
||
| 536 | 518 | if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) |
| 537 | 519 | { |
| 538 | 520 | return $this->incBalance(); |
| 539 | - } |
|
| 540 | - else |
|
| 521 | + } else |
|
| 541 | 522 | { |
| 542 | 523 | return $this; |
| 543 | 524 | } |
| 544 | - } |
|
| 545 | - else |
|
| 525 | + } else |
|
| 546 | 526 | { |
| 547 | 527 | $this->left->key = $this->key; |
| 548 | 528 | $this->left->value = $this->value; |
@@ -552,16 +532,14 @@ discard block |
||
| 552 | 532 | $this->right->left = $this->left; |
| 553 | 533 | |
| 554 | 534 | return $this->right; |
| 555 | - } |
|
| 556 | - else |
|
| 535 | + } else |
|
| 557 | 536 | { |
| 558 | 537 | if ($this->left->right == $this) |
| 559 | 538 | { |
| 560 | 539 | $this->left->information &= ~ 1; |
| 561 | 540 | |
| 562 | 541 | return $this->right; |
| 563 | - } |
|
| 564 | - else |
|
| 542 | + } else |
|
| 565 | 543 | { |
| 566 | 544 | $this->right->information &= ~ 2; |
| 567 | 545 | |
@@ -597,8 +575,7 @@ discard block |
||
| 597 | 575 | return $this->incBalance(); |
| 598 | 576 | } |
| 599 | 577 | } |
| 600 | - } |
|
| 601 | - elseif ($cmp > 0) |
|
| 578 | + } elseif ($cmp > 0) |
|
| 602 | 579 | { |
| 603 | 580 | if ($this->information & 1) |
| 604 | 581 | { |
@@ -610,8 +587,7 @@ discard block |
||
| 610 | 587 | return $this->decBalance(); |
| 611 | 588 | } |
| 612 | 589 | } |
| 613 | - } |
|
| 614 | - else |
|
| 590 | + } else |
|
| 615 | 591 | { |
| 616 | 592 | if ($this->information & 1) |
| 617 | 593 | { |
@@ -622,8 +598,7 @@ discard block |
||
| 622 | 598 | { |
| 623 | 599 | return $this->decBalance(); |
| 624 | 600 | } |
| 625 | - } |
|
| 626 | - else |
|
| 601 | + } else |
|
| 627 | 602 | { |
| 628 | 603 | $left = $this->left; |
| 629 | 604 | $right = $this->right; |
@@ -633,22 +608,19 @@ discard block |
||
| 633 | 608 | $left->right = $right; |
| 634 | 609 | |
| 635 | 610 | return $left; |
| 636 | - } |
|
| 637 | - else |
|
| 611 | + } else |
|
| 638 | 612 | { |
| 639 | 613 | if ($left && $left->right == $this) |
| 640 | 614 | { |
| 641 | 615 | $left->information &= ~ 1; |
| 642 | 616 | |
| 643 | 617 | return $right; |
| 644 | - } |
|
| 645 | - elseif ($right && $right->left == $this) |
|
| 618 | + } elseif ($right && $right->left == $this) |
|
| 646 | 619 | { |
| 647 | 620 | $right->information &= ~ 2; |
| 648 | 621 | |
| 649 | 622 | return $left; |
| 650 | - } |
|
| 651 | - else |
|
| 623 | + } else |
|
| 652 | 624 | { |
| 653 | 625 | return null; |
| 654 | 626 | } |
@@ -274,8 +274,7 @@ |
||
| 274 | 274 | try |
| 275 | 275 | { |
| 276 | 276 | return (bool) $this->map->find($element); |
| 277 | - } |
|
| 278 | - catch (\OutOfBoundsException $e) |
|
| 277 | + } catch (\OutOfBoundsException $e) |
|
| 279 | 278 | { |
| 280 | 279 | return false; |
| 281 | 280 | } |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | { |
| 68 | 68 | if ($comparator == null) |
| 69 | 69 | { |
| 70 | - $this->comparator = function ($key1, $key2) |
|
| 70 | + $this->comparator = function($key1, $key2) |
|
| 71 | 71 | { |
| 72 | 72 | return $key1 - $key2; |
| 73 | 73 | }; |
@@ -71,8 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | return $key1 - $key2; |
| 73 | 73 | }; |
| 74 | - } |
|
| 75 | - else |
|
| 74 | + } else |
|
| 76 | 75 | { |
| 77 | 76 | $this->comparator = $comparator; |
| 78 | 77 | } |
@@ -118,8 +117,7 @@ discard block |
||
| 118 | 117 | if ($this->root) |
| 119 | 118 | { |
| 120 | 119 | return $this->root->first; |
| 121 | - } |
|
| 122 | - else |
|
| 120 | + } else |
|
| 123 | 121 | { |
| 124 | 122 | throw new \OutOfBoundsException('First element unexisting'); |
| 125 | 123 | } |
@@ -139,8 +137,7 @@ discard block |
||
| 139 | 137 | if ($this->root) |
| 140 | 138 | { |
| 141 | 139 | return $this->root->last; |
| 142 | - } |
|
| 143 | - else |
|
| 140 | + } else |
|
| 144 | 141 | { |
| 145 | 142 | throw new \OutOfBoundsException('Last element unexisting'); |
| 146 | 143 | } |
@@ -164,8 +161,7 @@ discard block |
||
| 164 | 161 | if ($predecessor) |
| 165 | 162 | { |
| 166 | 163 | return $predecessor; |
| 167 | - } |
|
| 168 | - else |
|
| 164 | + } else |
|
| 169 | 165 | { |
| 170 | 166 | throw new \OutOfBoundsException('Predecessor element unexisting'); |
| 171 | 167 | } |
@@ -189,8 +185,7 @@ discard block |
||
| 189 | 185 | if ($successor) |
| 190 | 186 | { |
| 191 | 187 | return $successor; |
| 192 | - } |
|
| 193 | - else |
|
| 188 | + } else |
|
| 194 | 189 | { |
| 195 | 190 | throw new \OutOfBoundsException('Successor element unexisting'); |
| 196 | 191 | } |
@@ -212,8 +207,7 @@ discard block |
||
| 212 | 207 | if ($this->root) |
| 213 | 208 | { |
| 214 | 209 | $lower = $this->root->find($key, $this->comparator, -2); |
| 215 | - } |
|
| 216 | - else |
|
| 210 | + } else |
|
| 217 | 211 | { |
| 218 | 212 | $lower = null; |
| 219 | 213 | } |
@@ -221,8 +215,7 @@ discard block |
||
| 221 | 215 | if ($lower) |
| 222 | 216 | { |
| 223 | 217 | return $lower; |
| 224 | - } |
|
| 225 | - else |
|
| 218 | + } else |
|
| 226 | 219 | { |
| 227 | 220 | throw new \OutOfBoundsException('Lower element unexisting'); |
| 228 | 221 | } |
@@ -244,8 +237,7 @@ discard block |
||
| 244 | 237 | if ($this->root) |
| 245 | 238 | { |
| 246 | 239 | $floor = $this->root->find($key, $this->comparator, -1); |
| 247 | - } |
|
| 248 | - else |
|
| 240 | + } else |
|
| 249 | 241 | { |
| 250 | 242 | $floor = null; |
| 251 | 243 | } |
@@ -253,8 +245,7 @@ discard block |
||
| 253 | 245 | if ($floor) |
| 254 | 246 | { |
| 255 | 247 | return $floor; |
| 256 | - } |
|
| 257 | - else |
|
| 248 | + } else |
|
| 258 | 249 | { |
| 259 | 250 | throw new \OutOfBoundsException('Floor element unexisting'); |
| 260 | 251 | } |
@@ -276,8 +267,7 @@ discard block |
||
| 276 | 267 | if ($this->root) |
| 277 | 268 | { |
| 278 | 269 | $find = $this->root->find($key, $this->comparator, 0); |
| 279 | - } |
|
| 280 | - else |
|
| 270 | + } else |
|
| 281 | 271 | { |
| 282 | 272 | $find = null; |
| 283 | 273 | } |
@@ -285,8 +275,7 @@ discard block |
||
| 285 | 275 | if ($find) |
| 286 | 276 | { |
| 287 | 277 | return $find; |
| 288 | - } |
|
| 289 | - else |
|
| 278 | + } else |
|
| 290 | 279 | { |
| 291 | 280 | throw new \OutOfBoundsException('Element unexisting'); |
| 292 | 281 | } |
@@ -308,8 +297,7 @@ discard block |
||
| 308 | 297 | if ($this->root) |
| 309 | 298 | { |
| 310 | 299 | $ceiling = $this->root->find($key, $this->comparator, 1); |
| 311 | - } |
|
| 312 | - else |
|
| 300 | + } else |
|
| 313 | 301 | { |
| 314 | 302 | $ceiling = null; |
| 315 | 303 | } |
@@ -317,8 +305,7 @@ discard block |
||
| 317 | 305 | if ($ceiling) |
| 318 | 306 | { |
| 319 | 307 | return $ceiling; |
| 320 | - } |
|
| 321 | - else |
|
| 308 | + } else |
|
| 322 | 309 | { |
| 323 | 310 | throw new \OutOfBoundsException('Ceiling element unexisting'); |
| 324 | 311 | } |
@@ -340,8 +327,7 @@ discard block |
||
| 340 | 327 | if ($this->root) |
| 341 | 328 | { |
| 342 | 329 | $higher = $this->root->find($key, $this->comparator, 2); |
| 343 | - } |
|
| 344 | - else |
|
| 330 | + } else |
|
| 345 | 331 | { |
| 346 | 332 | $higher = null; |
| 347 | 333 | } |
@@ -349,8 +335,7 @@ discard block |
||
| 349 | 335 | if ($higher) |
| 350 | 336 | { |
| 351 | 337 | return $higher; |
| 352 | - } |
|
| 353 | - else |
|
| 338 | + } else |
|
| 354 | 339 | { |
| 355 | 340 | throw new \OutOfBoundsException('Higher element unexisting'); |
| 356 | 341 | } |
@@ -460,8 +445,7 @@ discard block |
||
| 460 | 445 | if ($this->root) |
| 461 | 446 | { |
| 462 | 447 | $this->root = $this->root->insert($key, $value, $this->comparator); |
| 463 | - } |
|
| 464 | - else |
|
| 448 | + } else |
|
| 465 | 449 | { |
| 466 | 450 | $this->root = TreeNode::create($key, $value); |
| 467 | 451 | } |
@@ -496,8 +480,7 @@ discard block |
||
| 496 | 480 | if ($this->root) |
| 497 | 481 | { |
| 498 | 482 | return count($this->root); |
| 499 | - } |
|
| 500 | - else |
|
| 483 | + } else |
|
| 501 | 484 | { |
| 502 | 485 | return 0; |
| 503 | 486 | } |
@@ -131,8 +131,7 @@ |
||
| 131 | 131 | if ($value) |
| 132 | 132 | { |
| 133 | 133 | $map[$element] = true; |
| 134 | - } |
|
| 135 | - else |
|
| 134 | + } else |
|
| 136 | 135 | { |
| 137 | 136 | unset($map[$element]); |
| 138 | 137 | } |
@@ -385,8 +385,7 @@ discard block |
||
| 385 | 385 | try |
| 386 | 386 | { |
| 387 | 387 | return $this->find($key)->value; |
| 388 | - } |
|
| 389 | - catch (\OutOfBoundsException $e) |
|
| 388 | + } catch (\OutOfBoundsException $e) |
|
| 390 | 389 | { |
| 391 | 390 | throw new \OutOfRangeException('Undefined offset'); |
| 392 | 391 | } |
@@ -406,8 +405,7 @@ discard block |
||
| 406 | 405 | try |
| 407 | 406 | { |
| 408 | 407 | return (bool) $this->find($key); |
| 409 | - } |
|
| 410 | - catch (\OutOfBoundsException $e) |
|
| 408 | + } catch (\OutOfBoundsException $e) |
|
| 411 | 409 | { |
| 412 | 410 | return false; |
| 413 | 411 | } |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | try |
| 144 | 144 | { |
| 145 | 145 | $this->current = $this->map->first(); |
| 146 | - } |
|
| 147 | - catch (\OutOfBoundsException $e) |
|
| 146 | + } catch (\OutOfBoundsException $e) |
|
| 148 | 147 | { |
| 149 | 148 | $this->current = null; |
| 150 | 149 | } |
@@ -162,8 +161,7 @@ discard block |
||
| 162 | 161 | if ($this->type == self::PAIRS) |
| 163 | 162 | { |
| 164 | 163 | return $this->current->key; |
| 165 | - } |
|
| 166 | - else |
|
| 164 | + } else |
|
| 167 | 165 | { |
| 168 | 166 | return $this->index; |
| 169 | 167 | } |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | if ($this->type == self::KEYS) |
| 182 | 180 | { |
| 183 | 181 | return $this->current->key; |
| 184 | - } |
|
| 185 | - else |
|
| 182 | + } else |
|
| 186 | 183 | { |
| 187 | 184 | return $this->current->value; |
| 188 | 185 | } |
@@ -200,8 +197,7 @@ discard block |
||
| 200 | 197 | try |
| 201 | 198 | { |
| 202 | 199 | $this->current = $this->map->successor($this->current); |
| 203 | - } |
|
| 204 | - catch (\OutOfBoundsException $e) |
|
| 200 | + } catch (\OutOfBoundsException $e) |
|
| 205 | 201 | { |
| 206 | 202 | $this->current = null; |
| 207 | 203 | } |
@@ -67,9 +67,9 @@ |
||
| 67 | 67 | protected function __construct(SortedMap $map) |
| 68 | 68 | { |
| 69 | 69 | $this->map = $map; |
| 70 | - $this->comparator = function ($key1, $key2) |
|
| 70 | + $this->comparator = function($key1, $key2) |
|
| 71 | 71 | { |
| 72 | - return - call_user_func($this->map->comparator, $key1, $key2); |
|
| 72 | + return -call_user_func($this->map->comparator, $key1, $key2); |
|
| 73 | 73 | }; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * This file is part of the php-sorted-collections package https://github.com/chdemko/php-sorted-collections |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 17 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 18 | 18 | |
| 19 | 19 | use chdemko\SortedCollection\TreeMap; |
| 20 | 20 | |
| 21 | 21 | date_default_timezone_set('UTC'); |
| 22 | -printf('TreeMap benchmarking run on ' . date('r') . PHP_EOL . PHP_EOL); |
|
| 23 | -printf('%25s %10s %10s %10s' . PHP_EOL, 'Operation', 'n', 'seconds', 'μs/(n log(n))'); |
|
| 24 | -printf('-------------------------------------------------------------' . PHP_EOL); |
|
| 22 | +printf('TreeMap benchmarking run on '.date('r').PHP_EOL.PHP_EOL); |
|
| 23 | +printf('%25s %10s %10s %10s'.PHP_EOL, 'Operation', 'n', 'seconds', 'μs/(n log(n))'); |
|
| 24 | +printf('-------------------------------------------------------------'.PHP_EOL); |
|
| 25 | 25 | |
| 26 | 26 | $tree = TreeMap::create(); |
| 27 | 27 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $end = microtime(true); |
| 38 | 38 | |
| 39 | 39 | printf( |
| 40 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 40 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 41 | 41 | 'Insert all elements', |
| 42 | 42 | $count, |
| 43 | 43 | $end - $start, |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $end = microtime(true); |
| 65 | 65 | |
| 66 | 66 | printf( |
| 67 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 67 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 68 | 68 | 'Remove all elements', |
| 69 | 69 | $count, |
| 70 | 70 | $end - $start, |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $end = microtime(true); |
| 92 | 92 | |
| 93 | 93 | printf( |
| 94 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 94 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 95 | 95 | 'Search all elements', |
| 96 | 96 | $count, |
| 97 | 97 | $end - $start, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $end = microtime(true); |
| 118 | 118 | |
| 119 | 119 | printf( |
| 120 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 120 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 121 | 121 | 'Loop on all elements', |
| 122 | 122 | $count, |
| 123 | 123 | $end - $start, |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $end = microtime(true); |
| 142 | 142 | |
| 143 | 143 | printf( |
| 144 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 144 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 145 | 145 | 'Count all elements', |
| 146 | 146 | $count, |
| 147 | 147 | $end - $start, |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | * This file is part of the php-sorted-collections package https://github.com/chdemko/php-sorted-collections |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 17 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 18 | 18 | |
| 19 | 19 | use chdemko\SortedCollection\TreeMap; |
| 20 | 20 | use chdemko\SortedCollection\ReversedMap; |
| 21 | 21 | |
| 22 | 22 | date_default_timezone_set('UTC'); |
| 23 | -printf('ReversedMap benchmarking run on ' . date('r') . PHP_EOL . PHP_EOL); |
|
| 24 | -printf('%25s %10s %10s %10s' . PHP_EOL, 'Operation', 'n', 'seconds', 'μs/(n log(n))'); |
|
| 25 | -printf('-------------------------------------------------------------' . PHP_EOL); |
|
| 23 | +printf('ReversedMap benchmarking run on '.date('r').PHP_EOL.PHP_EOL); |
|
| 24 | +printf('%25s %10s %10s %10s'.PHP_EOL, 'Operation', 'n', 'seconds', 'μs/(n log(n))'); |
|
| 25 | +printf('-------------------------------------------------------------'.PHP_EOL); |
|
| 26 | 26 | |
| 27 | 27 | $tree = TreeMap::create(); |
| 28 | 28 | $reversed = ReversedMap::create($tree); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $end = microtime(true); |
| 45 | 45 | |
| 46 | 46 | printf( |
| 47 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 47 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 48 | 48 | 'Search all elements', |
| 49 | 49 | $count, |
| 50 | 50 | $end - $start, |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $end = microtime(true); |
| 71 | 71 | |
| 72 | 72 | printf( |
| 73 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 73 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 74 | 74 | 'Loop on all elements', |
| 75 | 75 | $count, |
| 76 | 76 | $end - $start, |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $end = microtime(true); |
| 95 | 95 | |
| 96 | 96 | printf( |
| 97 | - '%25s %10d %10.2f %10.2f' . PHP_EOL, |
|
| 97 | + '%25s %10d %10.2f %10.2f'.PHP_EOL, |
|
| 98 | 98 | 'Count all elements', |
| 99 | 99 | $count, |
| 100 | 100 | $end - $start, |