[1442bb]: Random.c Maximize Restore History

Download this file

Random.c    25 lines (18 with data), 499 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "AutoPanoSift.h"
#include <math.h>
#include <time.h>
/* This is a minimal subset of the C# Container Class Random */
Random* Random_new0() {
Random* self = (Random*)malloc(sizeof(Random));
srand(time(NULL));
return self;
}
void Random_delete(Random* self) {
free(self);
}
int Random_Next(Random* self, int min, int max) {
return min + (int)((rand()*(double)(max-min))/RAND_MAX);
}
double Random_NextDouble(Random* self) {
return ((double)(rand())/RAND_MAX);
}