System.Math.RandomFrom
Delphi
function RandomFrom(const AValues: array of ShortInt): ShortInt;
function RandomFrom(const AValues: array of SmallInt): SmallInt;
function RandomFrom(const AValues: array of Integer): Integer;
function RandomFrom(const AValues: array of Int64): Int64;
function RandomFrom(const AValues: array of Byte): Byte;
function RandomFrom(const AValues: array of Word): Word;
function RandomFrom(const AValues: array of Cardinal): Cardinal;
function RandomFrom(const AValues: array of UInt64): UInt64;
function RandomFrom(const AValues: array of Single): Single;
function RandomFrom(const AValues: array of Double): Double;
function RandomFrom(const AValues: array of Extended): Extended;
function RandomFrom(const AValues: array of Boolean): Boolean;
C++
extern DELPHI_PACKAGE System::Int8 __fastcall RandomFrom(const System::Int8 *AValues, const System::NativeInt AValues_High)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Math.pas System.Math.hpp |
System.Math | System.Math |
Description
Returns a randomly selected element from an array.
RandomFrom returns a randomly selected element from the array passed as the AValues argument. In C++, AValues_Size is the index of the last array element (one less than the number of elements.)
To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to RandomFrom.