Doctrine\Common\Collections\ArrayCollection::partition PHP Method

partition() public method

{@inheritDoc}
public partition ( Closure $p )
$p Closure
    public function partition(Closure $p)
    {
        $matches = $noMatches = array();
        foreach ($this->elements as $key => $element) {
            if ($p($key, $element)) {
                $matches[$key] = $element;
            } else {
                $noMatches[$key] = $element;
            }
        }
        return array($this->createFrom($matches), $this->createFrom($noMatches));
    }

Usage Example

 public function partition(Closure $p)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->partition($p);
 }
All Usage Examples Of Doctrine\Common\Collections\ArrayCollection::partition