protected function _getCombinationSubset(array $sourceDataSet, $subsetSize)
    {
        if (!isset($subsetSize) || $subsetSize < 0) {
            throw new \InvalidArgumentException('Subset size cannot be empty or less than 0');
        }
        
        $sourceSetSize = count($sourceDataSet);

        if ($subsetSize >= $sourceSetSize) {
            return [$sourceDataSet];
            
        } else if ($subsetSize == 1) {
            return array_chunk($sourceDataSet, 1, true);
            
        } else if ($subsetSize == 0) {
            return [];
        }

        $combinations = [];
        $setKeys      = array_keys($sourceDataSet);

        $pointer = new Pointer($sourceDataSet, $subsetSize);

        do {
            $combinations[] = $this->_getCombination($sourceDataSet, $setKeys, $pointer);
        } while ($pointer->advance());

        return $combinations;
    }
protected function _getCombinationSubset(array $sourceDataSet, $subsetSize)
    {
        if (!isset($subsetSize) || $subsetSize < 0) {
            throw new \InvalidArgumentException('Subset size cannot be empty or less than 0');
        }
        
        $sourceSetSize = count($sourceDataSet);

        if ($subsetSize >= $sourceSetSize) {
            return [$sourceDataSet];
            
        } else if ($subsetSize == 1) {
            return array_chunk($sourceDataSet, 1, true);
            
        } else if ($subsetSize == 0) {
            return [];
        }

        $combinations = [];
        $setKeys      = array_keys($sourceDataSet);

        $pointer = new Pointer($sourceDataSet, $subsetSize);

        do {
            $combinations[] = $this->_getCombination($sourceDataSet, $setKeys, $pointer);
        } while ($pointer->advance());

        return $combinations;
    }
protected function _getCombinationSubset ( array $ sourceDataSet , $ subsetSize ) { if ( ! isset ( $ subsetSize ) || $ subsetSize < 0 ) { throw new \ InvalidArgumentException ( 'Subset size cannot be empty or less than 0' ) ; } $ sourceSetSize = count ( $ sourceDataSet ) ; if ( $ subsetSize >= $ sourceSetSize ) { return [ $ sourceDataSet ] ; } else if ( $ subsetSize == 1 ) { return array_chunk ( $ sourceDataSet , 1 , true ) ; } else if ( $ subsetSize == 0 ) { return [ ] ; } $ combinations = [ ] ; $ setKeys = array_keys ( $ sourceDataSet ) ; $ pointer = new Pointer ( $ sourceDataSet , $ subsetSize ) ; do { $ combinations [ ] = $ this -> _getCombination ( $ sourceDataSet , $ setKeys , $ pointer ) ; } while ( $ pointer -> advance ( ) ) ; return $ combinations ; }
Calculates all the combinations of a given subset size.
@param array $sourceDataSet The source data from which to calculate combiantions.
@param int   $subsetSize    Size of the combinations to calculate
@return array
@throws \InvalidArgumentException if the subset size is not supplied
Calculates all the combinations of a given subset size .