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 */;
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
function | public | System.Math.pas System.Math.hpp |
System.Math | System.Math |
説明
配列からランダムに選択した要素を返します。
RandomFrom は、AValues 引数として渡された配列からランダムに選択した要素を返します。C++ では、AValues_Size は配列の最終要素のインデックス(要素数 - 1)です。
乱数ジェネレータを初期化するには、RandomFrom を呼び出す前に、Randomize を 1 回呼び出すか RandSeed 変数に値を代入します。