std::random_device
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <random>
|
||
class random_device; |
(dal C++11) | |
std::random_device è uniformemente distribuita intero generatore di numeri casuali, che produce numeri casuali non deterministici, se un non-deterministico di origine (ad esempio un dispositivo hardware) è disponibile per la realizzazione.Original:
std::random_device is a uniformly-distributed integer random number generator, which produces non-deterministic random numbers, if a non-deterministic source (e.g. a hardware device) is available to the implementation.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Membri tipi
Membro tipo
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
result_type
|
unsigned int
|
Membri funzioni
Original: Construction The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
costruisce il motore Original: constructs the engine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
operator= (cancellato) |
l'operatore di assegnazione è soppresso Original: the assignment operator is deleted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
avanza dello stato del motore e restituisce il valore generato Original: advances the engine's state and returns the generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
ottiene la stima dell'entropia per la non-deterministico generatore di numeri casuali Original: obtains the entropy estimate for the non-deterministic random number generator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
[statico] |
ottiene il valore più piccolo possibile nel campo di uscita Original: gets the smallest possible value in the output range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico statico) |
[statico] |
gets the largest possible value in the output range (metodo pubblico statico) |
Esempio
#include <iostream>
#include <string>
#include <map>
#include <random>
int main()
{
std::random_device rd;
std::map<int, int> hist;
for(int n=0; n<20000; ++n)
++hist[rd()%10];
for(auto p : hist)
std::cout << p.first << " : " << std::string(p.second/100, '*') << '\n';
}
Output:
0 : ********************
1 : *******************
2 : ********************
3 : ********************
4 : ********************
5 : *******************
6 : ********************
7 : ********************
8 : *******************
9 : ********************