tape.h 720 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // tape.hpp
  3. // shared_random_generator
  4. //
  5. // Created by Sam Jaffe on 3/19/23.
  6. // Copyright © 2023 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <utility>
  10. #include <vector>
  11. #include <random/device.h>
  12. namespace engine::random {
  13. class Tape : public Device {
  14. public:
  15. // Allow for the serialization and de-serialization of this Tape
  16. using serial_type = std::vector<result_type>;
  17. private:
  18. size_t index_{0}; // transient
  19. std::vector<result_type> entries_;
  20. public:
  21. Tape() = default;
  22. Tape(serial_type serial) : entries_(std::move(serial)) {}
  23. explicit operator serial_type() const { return entries_; }
  24. result_type operator()() override;
  25. result_type operator()(result_type result);
  26. };
  27. }