Pick a given number of random values with non-duplicate indexes out of the array.

@param int $number The number of values (should be > 1 and < $this->count())

@return array Random values of array

@throws \RangeException
494954
public function getRandomValues($number)
    {
        $values = [];

        $keys = $number > 1 ? $this->getRandomKeys($number) : [$this->getRandomKeys($number)];
        foreach ($keys as $key) {
            $values[] = $this->offsetGet($key);
        }

        return $values;
    }
315020
public function lastsImmutable(int $number = null): self
    {
        if ($this->isEmpty()) {
            return static::create(
                [],
                $this->iteratorClass,
                false
            );
        }

        if ($number === null) {
            $poppedValue = $this->last();

            if ($poppedValue === null) {
                $poppedValue = [$poppedValue];
            } else {
                $poppedValue = (array) $poppedValue;
            }

            $arrayy = static::create(
                $poppedValue,
                $this->iteratorClass,
                false
            );
        } else {
            $number = (int) $number;
            $arrayy = $this->rest(-$number);
        }

        return $arrayy;
    }
1247905
public function getFirstElements(int $number): AbstractLinkedList {
        $head = $this->getHead();
        //if there are more elements requested than the list provides
        $number = $number > $head->size() ? $head->size() : $number;
        $list = $this->getEmptyInstance();
        $i = 0;
        while ($i < $number) {
            //TODO append or prepend?
            $list->append($head);
            $head = $head->getNext();
            $i++;
        }
        return $list;
    }
611476
public static function perfectNumbers(int $n): array
    {
        if ($n <= 0) {
            return [];
        }

        if ($n <= 10) {
            return array_slice(self::PERFECT_NUMBERS, 0, $n);
        }

        throw new OutOfBoundsException("Perfect numbers beyond the tenth are too large to compute");
    }
1312644
protected function buildRandomIntegers($count, $max = null, $excludes = [], $unique = true)
    {
        $max = $max ?: $count;

        // If it should not be unique do the simple task
        if (!$unique) {
            $numbers = [];
            for ($i = 0; $i < $count; ++$i) {
                $numbers[] = rand(0, $max - 1);
            }

            return $numbers;
        }

        if ($count > $max && $unique) {
            throw new InvalidArgumentException("An array with $count unique values with more items than max ($max) is impossible");
        }

        // Generate numbers until max
        $numbers = range(0, $max - 1);

        // Remove all excludes from the numbers
        foreach ($excludes as $exclude) {
            if (isset($numbers[$exclude])) {
                unset($numbers[$exclude]);
            }
        }

        // If the numbers are less than count, add the excludes back until count

        $i = 0;
        while (count($numbers) < $count) {
            $numbers[] = $excludes[$i];
            ++$i;
        }

        shuffle($numbers);

        $slice = [];

        for ($i = 0, $n = 0; $i < $count; ++$i) {
            $slice[] = array_pop($numbers);
        }

        return $slice;
    }
381141
public function random($iCount = 1)
    {
        if ($this->isEmpty()) {
            return [];
        }

        $iCount = (int) trim($iCount);
        if ($iCount < 1) {
            $iCount = 1;
        }

        if (count($this->arElementIDList) < $iCount) {
            $iCount = count($this->arElementIDList);
        }

        $obThis = $this->copy();
        shuffle($obThis->arElementIDList);

        return $obThis->take($iCount);
    }
1064662
public static function SplitIntoSegments($number)
	{
		$number_str = $number->GetStringValue();
		$segments = [];
		$NumberSegments = [];

		while (strlen($number_str) > 0)
		{
			if (strlen($number_str) < 3)
			{
				$segments[] = $number_str;

				break;
			}

			$segment = substr($number_str, -3);
			$number_str = substr($number_str, 0, strlen($number_str) - 3);

			$segments[] = $segment;
		}

		return array_reverse($segments);
	}
645454
public function getMore($number = 0)
    {
        if ($this->finished || $this->destroyed) {
            return;
        }
        if (mb_orig_substr($this->id, 0, 1) === 'c') {
            $this->conn->pool->getMore($this->col, mb_orig_substr($this->id, 1), $number, $this->conn);
        }
    }
1263850
public function fetchLastMessages($number = 1)
    {
        $messages = $this->fetchMessages();

        $firstIndex = count($messages) - $number;

        $messages = array_slice($messages, $firstIndex, $number);

        $this->assertCount($number, $messages);

        return $messages;
    }
518606
public function pickRandom($n)
	{
		$rows = $this->rows;

		shuffle($rows);
		$randomRows = array_slice($rows, 0, $n);
		$rowsObject = new self($randomRows);

		return $rowsObject;
	}
576537
public function randomSubsetWithReplacement(int $n) : self
    {
        if ($n < 1) {
            throw new InvalidArgumentException('Cannot generate a subset of'
                . " less than 1 sample, $n given.");
        }

        $max = $this->numRows() - 1;

        $subset = [];

        for ($i = 0; $i < $n; $i++) {
            $subset[] = $this->samples[rand(0, $max)];
        }

        return self::quick($subset);
    }
1044653
public function withNumber($number, $variables = null)
    {
        if (!is_null($variables)) {
            $vars = array();
            foreach ($variables as $k => $v) {
                $vars[] = array('key' => $k, 'value' => $v);
            }
            $this->setArgument("variables", $vars);
        }
        return $this->setArgument("number", $number);
    }
652028
public function choose($line, $number, $locale)
    {
        $segments = explode('|', $line);

        if (($value = $this->extract($segments, $number)) !== null) {
            return trim($value);
        }

        $segments = $this->stripConditions($segments);

        $pluralIndex = $this->getPluralIndex($locale, $number);

        if (count($segments) === 1 || ! isset($segments[$pluralIndex])) {
            return $segments[0];
        }

        return $segments[$pluralIndex];
    }
141678
public static function getNextPermutation($number) {
    $length = strlen($number);
    $pieces = str_split($number);
    // Find non-increasing suffix
    $i = $length - 1;
    while ($i > 0 && $pieces[$i - 1] >= $pieces[$i]) {
      $i--;
    }
    if ($i <= 0) {
      return FALSE;
    }

    // Find successor to pivot.
    $j = $length - 1;
    while ($pieces[$j] <= $pieces[$i - 1]) {
      $j--;
    }
    $temp = $pieces[$i - 1];
    $pieces[$i - 1] = $pieces[$j];
    $pieces[$j] = $temp;

    // Reverse suffix
    $j = $length - 1;
    while ($i < $j) {
      $temp = $pieces[$i];
      $pieces[$i] = $pieces[$j];
      $pieces[$j] = $temp;
      $i++;
      $j--;
    }
    return implode('', $pieces);
  }
881445
public function get($number = 0)
    {
        if (isset($this->tokens[$this->current + $number])) {
            return $this->tokens[$this->current + $number];
        }
    }
1075130
public function setParcelNumber($number)
    {
        $this->set(Config::T8904, (string)$number);
        $this->set(Config::T8973, (string)$number);

        return $this;
    }
682903
public function setRange($range)
    {
        Argument::i()->test(1, 'int');
        
        if ($range < 0) {
            $range = 25;
        }
        
        $this->range = $range;
        
        return $this;
    }