src/Collection/ImmArray.php
public function unique()
    {
        $count = count($this->sfa);
        $unique = new SplFixedArray($count);
        $newCount = 0;
        $lastUnique = null;

        foreach ($this->sfa as $el) {
            for($i = $newCount; $i >= 0; $i--) {
                // going from back to forward to find sequence of duplicates faster
                if ($unique[$i] === $el) {
                    continue 2;
                }
            }
            $unique[$newCount++] = $el;
        }

        $unique->setSize($newCount);
        return new static($unique);
    }
public function unique()
    {
        $count = count($this->sfa);
        $unique = new SplFixedArray($count);
        $newCount = 0;
        $lastUnique = null;

        foreach ($this->sfa as $el) {
            for($i = $newCount; $i >= 0; $i--) {
                // going from back to forward to find sequence of duplicates faster
                if ($unique[$i] === $el) {
                    continue 2;
                }
            }
            $unique[$newCount++] = $el;
        }

        $unique->setSize($newCount);
        return new static($unique);
    }
public function unique ( ) { $ count = count ( $ this -> sfa ) ; $ unique = new SplFixedArray ( $ count ) ; $ newCount = 0 ; $ lastUnique = null ; foreach ( $ this -> sfa as $ el ) { for ( $ i = $ newCount ; $ i >= 0 ; $ i -- ) { // going from back to forward to find sequence of duplicates faster if ( $ unique [ $ i ] === $ el ) { continue 2 ; } } $ unique [ $ newCount ++ ] = $ el ; } $ unique -> setSize ( $ newCount ) ; return new static ( $ unique ) ; }
Filter out non-unique elements

@return static
Filter out non - unique elements