System.Math.RandomFrom
Delphi
function RandomFrom(const AValues: array of Integer): Integer;
function RandomFrom(const AValues: array of Int64): Int64;
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;
C++
extern DELPHI_PACKAGE int __fastcall RandomFrom(const int *AValues, const int 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 変数に値を代入します。