-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
executable file
·60 lines (52 loc) · 1.61 KB
/
util.h
File metadata and controls
executable file
·60 lines (52 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*************************************************************************
> File Name: common_define.h
> Author: hulkcao
> Mail: [email protected]
> Created Time: Sat 03 Aug 2019 03:26:23 AM UTC
************************************************************************/
#ifndef _COMMON_DEFINE_H
#define _COMMON_DEFINE_H
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LOG(...) \
do { \
printf("%s line %d:\t", __func__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n"); \
} while (0)
class RandomUtils {
public:
static int getInt(int start = 0, int end = INT_MAX) {
std::random_device rd;
std::default_random_engine e(rd());
std::uniform_int_distribution<int> u(start, end);
return u(e);
}
static double getDouble(double start = 0, double end = INT_MAX) {
std::random_device rd;
std::default_random_engine e(rd());
std::uniform_real_distribution<double> u(start, end);
return u(e);
}
};
namespace {
template <typename T> void printItemList(T &itemlist) {
for (auto &v : itemlist) {
std::cout << v << " ";
}
printf("\n");
}
} // namespace
#endif