random_set_element_generator.h 905 Bytes
Newer Older
Jonas Seidel's avatar
Jonas Seidel committed
1
2
3
4
5
#ifndef RANDOM_SET_ELEMENT_GENERATOR_H
#define RANDOM_SET_ELEMENT_GENERATOR_H

#include <cstddef>
#include <random>
6
#include <unordered_set>
Jonas Seidel's avatar
Jonas Seidel committed
7

8
9
10
11
12
enum generation_type{
  random_unused,
  random_all_static,
  random_all_dynamic
};
Jonas Seidel's avatar
Jonas Seidel committed
13
14
15

template <typename T>
class random_set_element_generator{
16
17
18
19
20
  static std::default_random_engine _engine;
  std::unordered_set<T>* _dynamic_set;
  std::unordered_set<T> _static_set;
  std::unordered_set<T> _current_run_set;
  generation_type _gen_type;
Jonas Seidel's avatar
Jonas Seidel committed
21
22

public:
23
24
  random_set_element_generator(std::unordered_set<T>* s, generation_type gen_type);
  random_set_element_generator(std::unordered_set<T> s, generation_type gen_type);
Jonas Seidel's avatar
Jonas Seidel committed
25

26
27
  void reset();
  bool has_next();
Jonas Seidel's avatar
Jonas Seidel committed
28
29
30
31
  T next();
  void operator>>(T& var);
};

32
template <typename T>
33
34
std::default_random_engine random_set_element_generator<T>::_engine((std::random_device())());

35
36
37



Jonas Seidel's avatar
Jonas Seidel committed
38
39
40
#include "random_set_element_generator.ipp"

#endif