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 */;
Propriétés
Type | Visibilité | Source | Unité | Parent |
---|---|---|---|---|
function | public | System.Math.pas System.Math.hpp |
System.Math | System.Math |
Description
Renvoie un élément choisi au hasard dans un tableau.
RandomFrom renvoie un élément choisi au hasard dans le tableau AValues transmis comme argument. Dans C++, AValues_Size est l'indice du dernier élément du tableau (nombre d'éléments moins un).
Pour initialiser le générateur de nombre aléatoire, ajoutez un seul appel Randomize ou affectez une valeur à la variable RandSeed avant d'effectuer un appel à RandomFrom.