//
//  SequenceRandomGenerator.hpp
//  eagle0
//
//  Created by Dan Crosby on 3/10/18.
//  Copyright © 2018 none. All rights reserved.
//

#ifndef SequenceRandomGenerator_h
#define SequenceRandomGenerator_h

#include <memory>
#include <vector>

#include "src/main/cpp/net/eagle0/common/RandomGenerator.hpp"

class SequenceRandomGenerator : public ::RandomGenerator {
private:
    const std::vector<double> sequence;
    size_t position = 0;

    auto DoubleZeroToOne() -> double override {
        const double nextVal = sequence[position];
        position++;
        if (position >= sequence.size()) { position = 0; }
        return nextVal;
    }

public:
    explicit SequenceRandomGenerator(std::vector<double> s) : sequence(std::move(s)), position(0) {}
    static auto WithSequence(const std::vector<double>& s)
            -> std::shared_ptr<SequenceRandomGenerator> {
        return std::make_shared<SequenceRandomGenerator>(s);
    }
};

#endif /* SequenceRandomGenerator_h */
