-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of Id class for Date/Float/Integer Values in 64 bits us…
…in bit-fiddling. Some unit tests, but no integration yet. Next step: Use for the vocabularyFloats (increase performance)
- Loading branch information
Showing
4 changed files
with
388 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Created by johannes on 04.05.20. | ||
// | ||
#include<random> | ||
|
||
#ifndef QLEVER_RANDOM_H | ||
#define QLEVER_RANDOM_H | ||
|
||
namespace ad_utility { | ||
|
||
template <typename INT> | ||
class RandomIntGenerator { | ||
std::random_device r_; | ||
std::default_random_engine engine_; | ||
std::uniform_int_distribution<INT> dist_; | ||
public: | ||
RandomIntGenerator(INT min = std::numeric_limits<INT>::min(), INT max = std::numeric_limits<INT>::max()) : | ||
r_(), engine_(r_()), dist_(min, max) {} | ||
|
||
INT operator()() { | ||
return dist_(engine_); | ||
} | ||
|
||
}; | ||
template <typename FLOAT> | ||
class RandomFloatGenerator { | ||
std::random_device r_; | ||
std::default_random_engine engine_; | ||
std::uniform_real_distribution<FLOAT> dist_; | ||
|
||
public: | ||
RandomFloatGenerator(FLOAT min = std::numeric_limits<FLOAT>::min(), FLOAT max = std::numeric_limits<FLOAT>::max()) : | ||
r_(), engine_(r_()), dist_(min, max) {} | ||
|
||
FLOAT operator()() { | ||
return dist_(engine_); | ||
} | ||
}; | ||
|
||
} | ||
|
||
#endif // QLEVER_RANDOM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.