MTEngine
A random number generator engine for C++ based on the Mersenne Twister algorithm.
Loading...
Searching...
No Matches
C:/Users/harshn/Desktop/MTEngine/example.cpp File Reference
#include "MTEngine.hpp"
#include "PrintUtils/PrintUtils.hpp"
#include <vector>
#include <iostream>
Include dependency graph for example.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

This is the main function where the execution of the program begins.

An instance of the MTEngine class is created. The MTEngine class is a pseudorandom number generator, based on the Mersenne Twister algorithm.

The rand() function of the MTEngine class is called to generate a random number. The generated number is then printed to the console.

The choice() function of the MTEngine class is called with three arguments: 1, 2, and 3. This function is assumed to randomly select and return one of the provided arguments. The selected number is then printed to the console.

A vector of doubles is created with the values 1, 2, 3, 4, and 5.

The Shuffle() function of the MTEngine class is called with the vector as an argument. This function is assumed to randomly rearrange the elements in the provided vector.

The contents of the vector are printed to the console. an overloaded operator<< for vectors from PrintUtils.hpp is used to print the vector.

The Choice() function of the MTEngine class is called with 15 arguments. This function is assumed to randomly select and return one of the provided arguments. The selected number is then printed to the console.

The main function returns 0, indicating successful execution of the program.

Definition at line 9 of file example.cpp.

10{
15
16 MTEngine engine;
17
21
22 std::cout << engine.rand() << std::endl;
23
28
29 std::cout << engine.choice(1, 2, 3) << std::endl;
30
33
34 std::vector<double> v = {1, 2, 3, 4, 5};
35
39
40 engine.Shuffle(v);
41
45
46 std::cout << v << std::endl;
47
48
53
54 std::cout<<engine.Choice(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)<<std::endl;
55
58
59 return 0;
60}
A class that represents a random number generator engine.
Definition MTEngine.hpp:22
T Choice(T Start, Args... args)
Definition MTEngine.hpp:100
void Shuffle(std::vector< T > &X)
Definition MTEngine.hpp:67
double choice(double a, double b)
Definition MTEngine.cpp:97
double rand()
Definition MTEngine.cpp:84
Here is the call graph for this function: