Pick one or more random entries.

@param int $num Specifies how many entries should be picked.

@return $this
353171
public function random($num = 1)
    {
        $count = \count($this->items);
        if ($num > $count) {
            $num = $count;
        }

        $this->items = array_intersect_key($this->items, array_flip((array)array_rand($this->items, $num)));

        return $this;
    }
801137
public function random()
    {
        $count = $this->count();
        switch ($count) {
            case 0:
                return null;
            case 1:
                return $this->one();
            default:
                $cursor = $this->skip(mt_rand(0, $count - 1))->limit(1);
                $cursor->rewind();
                return $cursor->current();
        }
    }
423518
public function mod(BN $num) {
        if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero());
        $res = clone($this);
        $res->bi = $res->bi->divR($num->bi);
        return $res;
    }
1091573
public OptionalSyntax take(int num) {
		getMessage().setMaxresults(num);
		QueryMessage mess = getMessage();
		return new OptionalSyntax(mess);
	}
1352893
private function encodeSignedNumber($num)
    {
        $sgn_num = $num << 1;
        if ($num < 0) {
            $sgn_num = ~($sgn_num);
        }
        return $this->encodeNumber($sgn_num);
    }
141055
public function getCall($num)
    {
        if (array_key_exists($num, $this->calls)) {

            return $this->calls[$num];
        }

        return null;
    }
379833
function take($numRows)
    {
        $this->getNodes()->limit = $numRows !== null ? new Limit($numRows) : null;
        return $this;
    }
1044447
private function numeric($num): void
    {
        //调节为整数
        $num = intval(round($num));

        //与id字段匹配
        $this->sql = " id=$num";
        $this->prepare = " id=?";
        $this->param = [$num];
    }
395463
public function withPolicyMapping(int $num): self
    {
        $state = clone $this;
        $state->_policyMapping = $num;
        return $state;
    }
1169674
public function setNumber($num)
    {
        $num = (int) $num;
        if ($num <= 0) {
            throw new \InvalidArgumentException(sprintf(
                    'Invalid Number "%s" - Polygon Coordinates Number Must Be '
                    . 'Greater Than Zero'
                    , $num
            ));
        }
        $count = count($this->getCoordinates());
        if ($num > $count) {
            throw new \OutOfBoundsException(sprintf(
                    'Given Coodrinates Number "%s" Is Greater Than The Actual '
                    . 'Coordinates Array Size "%s"'
                    , $num, $count
            ));
        }
        $this->count = $num;

        return $this;
    }
1303816
public function random($amount = 1)
		{
			if ($this->isEmpty()) return;

			$keys = array_rand($this->items, $amount);

			return is_array($keys) ? array_intersect_key($this->items, array_flip($keys)) : $this->items[$keys];
		}
1251124
public function pow(BN $num) {
        $res = clone($this);
        $res->bi = $res->bi->pow($num->bi);
        return $res;
    }
960336
public function iuand(BN $num) {
        $this->bi = $this->bi->binaryAnd($num->bi);
        return $this;
    }
438012
public function iadd(BN $num) {
        $this->bi = $this->bi->add($num->bi);
        return $this;
    }
82572
function random(int $num = 1) {
        $rand = \array_rand($this->data, $num);
        if(!\is_array($rand)) {
            $rand = array($rand);
        }
        
        $col = new self();
        foreach($rand as $key) {
            $col->set($key, $this->data[$key]);
        }
        
        return $col;
    }
794939
public function addSelect($fields)
    {
        if (func_num_args() > 1) {
            $fields = func_get_args();
        } elseif (!is_array($fields)) {
            $fields = array($fields);
        }
        foreach ($fields as $idx => $field) {
            $this->selectField($field, is_numeric($idx) ? null : $idx);
        }

        return $this;
    }
431804
public function limit($num)
    {
        $num = (integer) $num;
        $this->limit = $num;
        $this->mongoCursor->limit($num);
        return $this;
    }