MiniOB
1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
src
common
math
integer_generator.h
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2
miniob is licensed under Mulan PSL v2.
3
You can use this software according to the terms and conditions of the Mulan PSL v2.
4
You may obtain a copy of Mulan PSL v2 at:
5
http://license.coscl.org.cn/MulanPSL2
6
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9
See the Mulan PSL v2 for more details. */
10
11
//
12
// Created by Wangyunlai on 2023/05/04
13
//
14
15
#pragma once
16
17
#include "common/lang/random.h"
18
19
namespace
common {
20
21
class
IntegerGenerator
22
{
23
public
:
24
IntegerGenerator
(
int
min,
int
max) : distrib_(min, max) {}
25
26
IntegerGenerator
(
const
IntegerGenerator
&other) =
delete
;
27
IntegerGenerator
(
IntegerGenerator
&&) =
delete
;
28
IntegerGenerator
&operator=(
const
IntegerGenerator
&) =
delete
;
29
30
int
next() {
return
distrib_(rd_); }
31
int
min()
const
{
return
distrib_.min(); }
32
int
max()
const
{
return
distrib_.max(); }
33
34
private
:
35
random_device rd_;
36
uniform_int_distribution<> distrib_;
37
};
38
39
}
// namespace common
common::IntegerGenerator
Definition:
integer_generator.h:22
制作者
1.9.5