예제 #1
0
 public function setTokens(array $tokens)
 {
     $this->tokens = array_unique_union($this->tokens, $tokens);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function union(ListInterface $list)
 {
     $this->executeIterator();
     return new ArrayList(array_unique_union($this->items, $list->all()));
 }
예제 #3
0
<?php

use Wandu\Fastelper\Bench;
require __DIR__ . '/../vendor/autoload.php';
$x = [];
$y = [];
for ($i = 0; $i < 1000; $i++) {
    if (rand(0, 100) === 0) {
        $x[] = $i;
    }
    if (rand(0, 100) === 0) {
        $y[] = $i;
    }
}
echo "x : ", count($x), "\n";
echo "y : ", count($y), "\n";
shuffle($x);
shuffle($y);
$bench = new Bench();
$bench->run(function () use(&$x, &$y) {
    return array_unique(array_merge($x, $y));
});
$bench->run(function () use(&$x, &$y) {
    return array_unique_union($x, $y);
});
예제 #4
0
 public function testUniqueUnion()
 {
     $this->assertEqualSet([1, 2, 4, 5], array_unique_union([1, 4, 5, 5, 5], [1, 2]));
 }