getAllTargets() публичный Метод

A list of all potential targets.
public getAllTargets ( ) : array
Результат array
Пример #1
0
 public function testRemoveTarget()
 {
     $hashSpace = new Flexihash();
     $hashSpace->addTarget('t-a')->addTarget('t-b')->addTarget('t-c')->removeTarget('t-b');
     $this->assertEquals($hashSpace->getAllTargets(), ['t-a', 't-c']);
 }
Пример #2
0
 public function testHashDistributionWithCrc32Hasher()
 {
     $hashSpace = new Flexihash(new Crc32Hasher());
     foreach (range(1, $this->_targets) as $i) {
         $hashSpace->addTarget("target{$i}");
     }
     $results = array();
     foreach (range(1, $this->_lookups) as $i) {
         $results[$i] = $hashSpace->lookup("t{$i}");
     }
     $distribution = array();
     foreach ($hashSpace->getAllTargets() as $target) {
         $distribution[$target] = count(array_keys($results, $target));
     }
     echo sprintf("\nDistribution of %d lookups per target (min/max/median/avg): %d/%d/%d/%d \n", $this->_lookups / $this->_targets, min($distribution), max($distribution), round($this->_median($distribution)), round(array_sum($distribution) / count($distribution)));
 }