|
@@ -9,9 +9,7 @@
|
|
|
#ifndef DORAYME_SEQUENCE_H
|
|
|
#define DORAYME_SEQUENCE_H
|
|
|
|
|
|
-#include <stdlib.h>
|
|
|
#include <stdint.h>
|
|
|
-#include <time.h>
|
|
|
|
|
|
class Sequence
|
|
|
{
|
|
@@ -20,30 +18,9 @@ private:
|
|
|
uint32_t listPos;
|
|
|
uint32_t listSize;
|
|
|
public:
|
|
|
- Sequence() : list(nullptr), listPos(0), listSize(0) {
|
|
|
- /* Need to bootstrap rand here */
|
|
|
- srand(time(NULL));
|
|
|
- }
|
|
|
- Sequence(double *list, uint32_t listSize) : list(list), listPos(0), listSize(listSize) { };
|
|
|
-
|
|
|
- static double frand(void)
|
|
|
- {
|
|
|
- return rand() / ((double) RAND_MAX);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- double next() {
|
|
|
- if (this->listSize == 0)
|
|
|
- {
|
|
|
- return frand();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- uint32_t pos = this->listPos;
|
|
|
- this->listPos = (this->listPos + 1) % this->listSize;
|
|
|
- return this->list[pos];
|
|
|
- }
|
|
|
- }
|
|
|
+ Sequence();
|
|
|
+ Sequence(double *list, uint32_t listSize);
|
|
|
+ double next();
|
|
|
};
|
|
|
|
|
|
|