예제 #1
0
 public function removeIf(PredicateInterface $predicate) : bool
 {
     $changed = false;
     foreach ($this as $x) {
         if ($predicate->test($x) && $this->remove($x) && !$changed) {
             $changed = true;
         }
     }
     return $changed;
 }
예제 #2
0
 public static final function filter(\Traversable $traversable, PredicateInterface $predicate) : \Traversable
 {
     $result = new \ArrayIterator();
     foreach ($traversable as $value) {
         if ($predicate->test($value)) {
             $result->append($value);
         }
     }
     return $result;
 }
예제 #3
0
 public static final function none(array $array, PredicateInterface $predicate) : bool
 {
     return self::all($array, $predicate->not());
 }