catboost 1.25.1 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPLOYMENT.md +22 -15
- package/README.md +37 -27
- package/binding.gyp +5 -7
- package/build_scripts/bootstrap.js +2 -1
- package/build_scripts/out/build.js +46 -68
- package/build_scripts/out/build_model.js +1 -1
- package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
- package/build_scripts/out/ci.js +5 -5
- package/build_scripts/out/config.js +32 -18
- package/build_scripts/out/install.js +5 -3
- package/build_scripts/out/package_prepublish.js +1 -1
- package/build_scripts/out/packaging.js +1 -19
- package/build_scripts/out/run_tests.js +1 -1
- package/build_scripts/out/test.js +8 -3
- package/config.json +18 -11
- package/inc/catboost/libs/model_interface/c_api.h +349 -3
- package/lib/catboost.d.ts +65 -21
- package/package.json +4 -4
- package/src/api_helpers.cpp +100 -24
- package/src/api_helpers.h +8 -7
- package/src/api_module.cpp +1 -2
- package/src/model.cpp +483 -83
- package/src/model.h +24 -9
- package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
- package/inc/util/charset/recode_result.h +0 -9
- package/inc/util/charset/unicode_table.h +0 -123
- package/inc/util/charset/unidata.h +0 -421
- package/inc/util/charset/utf8.h +0 -384
- package/inc/util/charset/wide.h +0 -843
- package/inc/util/charset/wide_specific.h +0 -22
- package/inc/util/datetime/base.h +0 -669
- package/inc/util/datetime/constants.h +0 -7
- package/inc/util/datetime/cputimer.h +0 -124
- package/inc/util/datetime/parser.h +0 -292
- package/inc/util/datetime/systime.h +0 -47
- package/inc/util/datetime/uptime.h +0 -8
- package/inc/util/digest/city.h +0 -88
- package/inc/util/digest/fnv.h +0 -73
- package/inc/util/digest/multi.h +0 -14
- package/inc/util/digest/murmur.h +0 -57
- package/inc/util/digest/numeric.h +0 -86
- package/inc/util/digest/sequence.h +0 -48
- package/inc/util/draft/date.h +0 -129
- package/inc/util/draft/datetime.h +0 -184
- package/inc/util/draft/enum.h +0 -136
- package/inc/util/draft/holder_vector.h +0 -102
- package/inc/util/draft/ip.h +0 -131
- package/inc/util/draft/matrix.h +0 -108
- package/inc/util/draft/memory.h +0 -40
- package/inc/util/folder/dirent_win.h +0 -46
- package/inc/util/folder/dirut.h +0 -121
- package/inc/util/folder/filelist.h +0 -81
- package/inc/util/folder/fts.h +0 -108
- package/inc/util/folder/iterator.h +0 -109
- package/inc/util/folder/lstat_win.h +0 -20
- package/inc/util/folder/path.h +0 -225
- package/inc/util/folder/pathsplit.h +0 -113
- package/inc/util/folder/tempdir.h +0 -42
- package/inc/util/generic/adaptor.h +0 -134
- package/inc/util/generic/algorithm.h +0 -765
- package/inc/util/generic/array_ref.h +0 -282
- package/inc/util/generic/array_size.h +0 -24
- package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
- package/inc/util/generic/bitmap.h +0 -1115
- package/inc/util/generic/bitops.h +0 -459
- package/inc/util/generic/bt_exception.h +0 -24
- package/inc/util/generic/buffer.h +0 -232
- package/inc/util/generic/cast.h +0 -176
- package/inc/util/generic/deque.h +0 -24
- package/inc/util/generic/explicit_type.h +0 -42
- package/inc/util/generic/fastqueue.h +0 -55
- package/inc/util/generic/flags.h +0 -244
- package/inc/util/generic/function.h +0 -103
- package/inc/util/generic/fwd.h +0 -171
- package/inc/util/generic/guid.h +0 -61
- package/inc/util/generic/hash.h +0 -2032
- package/inc/util/generic/hash_primes.h +0 -140
- package/inc/util/generic/hash_set.h +0 -490
- package/inc/util/generic/hide_ptr.h +0 -3
- package/inc/util/generic/intrlist.h +0 -876
- package/inc/util/generic/is_in.h +0 -53
- package/inc/util/generic/iterator.h +0 -137
- package/inc/util/generic/iterator_range.h +0 -105
- package/inc/util/generic/lazy_value.h +0 -66
- package/inc/util/generic/list.h +0 -22
- package/inc/util/generic/map.h +0 -44
- package/inc/util/generic/mapfindptr.h +0 -60
- package/inc/util/generic/maybe.h +0 -713
- package/inc/util/generic/maybe_traits.h +0 -164
- package/inc/util/generic/mem_copy.h +0 -55
- package/inc/util/generic/noncopyable.h +0 -38
- package/inc/util/generic/object_counter.h +0 -53
- package/inc/util/generic/ptr.h +0 -1113
- package/inc/util/generic/queue.h +0 -57
- package/inc/util/generic/refcount.h +0 -162
- package/inc/util/generic/reserve.h +0 -11
- package/inc/util/generic/scope.h +0 -65
- package/inc/util/generic/serialized_enum.h +0 -406
- package/inc/util/generic/set.h +0 -42
- package/inc/util/generic/singleton.h +0 -136
- package/inc/util/generic/size_literals.h +0 -65
- package/inc/util/generic/stack.h +0 -18
- package/inc/util/generic/store_policy.h +0 -120
- package/inc/util/generic/strbase.h +0 -612
- package/inc/util/generic/strbuf.h +0 -552
- package/inc/util/generic/strfcpy.h +0 -17
- package/inc/util/generic/string.h +0 -1572
- package/inc/util/generic/string_hash.h +0 -21
- package/inc/util/generic/string_ut.h +0 -1175
- package/inc/util/generic/type_name.h +0 -34
- package/inc/util/generic/typelist.h +0 -114
- package/inc/util/generic/typetraits.h +0 -325
- package/inc/util/generic/utility.h +0 -132
- package/inc/util/generic/va_args.h +0 -400
- package/inc/util/generic/variant.h +0 -631
- package/inc/util/generic/variant_traits.h +0 -171
- package/inc/util/generic/vector.h +0 -119
- package/inc/util/generic/xrange.h +0 -258
- package/inc/util/generic/yexception.h +0 -212
- package/inc/util/generic/yexception_ut.h +0 -14
- package/inc/util/generic/ylimits.h +0 -92
- package/inc/util/generic/ymath.h +0 -206
- package/inc/util/memory/addstorage.h +0 -93
- package/inc/util/memory/alloc.h +0 -27
- package/inc/util/memory/blob.h +0 -296
- package/inc/util/memory/mmapalloc.h +0 -8
- package/inc/util/memory/pool.h +0 -432
- package/inc/util/memory/segmented_string_pool.h +0 -194
- package/inc/util/memory/segpool_alloc.h +0 -118
- package/inc/util/memory/smallobj.h +0 -141
- package/inc/util/memory/tempbuf.h +0 -111
- package/inc/util/network/address.h +0 -136
- package/inc/util/network/endpoint.h +0 -61
- package/inc/util/network/hostip.h +0 -16
- package/inc/util/network/init.h +0 -60
- package/inc/util/network/interface.h +0 -17
- package/inc/util/network/iovec.h +0 -65
- package/inc/util/network/ip.h +0 -116
- package/inc/util/network/nonblock.h +0 -8
- package/inc/util/network/pair.h +0 -9
- package/inc/util/network/poller.h +0 -58
- package/inc/util/network/pollerimpl.h +0 -707
- package/inc/util/network/sock.h +0 -608
- package/inc/util/network/socket.h +0 -421
- package/inc/util/random/common_ops.h +0 -130
- package/inc/util/random/easy.h +0 -47
- package/inc/util/random/entropy.h +0 -21
- package/inc/util/random/fast.h +0 -101
- package/inc/util/random/init_atfork.h +0 -3
- package/inc/util/random/lcg_engine.h +0 -66
- package/inc/util/random/mersenne.h +0 -46
- package/inc/util/random/mersenne32.h +0 -50
- package/inc/util/random/mersenne64.h +0 -50
- package/inc/util/random/normal.h +0 -38
- package/inc/util/random/random.h +0 -30
- package/inc/util/random/shuffle.h +0 -39
- package/inc/util/str_stl.h +0 -266
- package/inc/util/stream/aligned.h +0 -99
- package/inc/util/stream/buffer.h +0 -119
- package/inc/util/stream/buffered.h +0 -225
- package/inc/util/stream/debug.h +0 -53
- package/inc/util/stream/direct_io.h +0 -43
- package/inc/util/stream/file.h +0 -108
- package/inc/util/stream/format.h +0 -444
- package/inc/util/stream/fwd.h +0 -100
- package/inc/util/stream/hex.h +0 -8
- package/inc/util/stream/holder.h +0 -44
- package/inc/util/stream/input.h +0 -273
- package/inc/util/stream/labeled.h +0 -19
- package/inc/util/stream/length.h +0 -100
- package/inc/util/stream/mem.h +0 -255
- package/inc/util/stream/multi.h +0 -32
- package/inc/util/stream/null.h +0 -61
- package/inc/util/stream/output.h +0 -304
- package/inc/util/stream/pipe.h +0 -112
- package/inc/util/stream/printf.h +0 -25
- package/inc/util/stream/str.h +0 -207
- package/inc/util/stream/tee.h +0 -28
- package/inc/util/stream/tempbuf.h +0 -21
- package/inc/util/stream/tokenizer.h +0 -214
- package/inc/util/stream/trace.h +0 -60
- package/inc/util/stream/walk.h +0 -35
- package/inc/util/stream/zerocopy.h +0 -91
- package/inc/util/stream/zerocopy_output.h +0 -57
- package/inc/util/stream/zlib.h +0 -173
- package/inc/util/string/ascii.h +0 -236
- package/inc/util/string/builder.h +0 -39
- package/inc/util/string/cast.h +0 -347
- package/inc/util/string/cstriter.h +0 -14
- package/inc/util/string/escape.h +0 -70
- package/inc/util/string/hex.h +0 -59
- package/inc/util/string/join.h +0 -194
- package/inc/util/string/printf.h +0 -13
- package/inc/util/string/reverse.h +0 -16
- package/inc/util/string/split.h +0 -1080
- package/inc/util/string/strip.h +0 -257
- package/inc/util/string/strspn.h +0 -65
- package/inc/util/string/subst.h +0 -56
- package/inc/util/string/type.h +0 -50
- package/inc/util/string/util.h +0 -195
- package/inc/util/string/vector.h +0 -132
- package/inc/util/system/align.h +0 -50
- package/inc/util/system/atexit.h +0 -22
- package/inc/util/system/atomic.h +0 -51
- package/inc/util/system/atomic_gcc.h +0 -90
- package/inc/util/system/atomic_ops.h +0 -189
- package/inc/util/system/atomic_win.h +0 -114
- package/inc/util/system/backtrace.h +0 -39
- package/inc/util/system/byteorder.h +0 -186
- package/inc/util/system/compat.h +0 -84
- package/inc/util/system/compiler.h +0 -620
- package/inc/util/system/condvar.h +0 -71
- package/inc/util/system/context.h +0 -181
- package/inc/util/system/context_aarch64.h +0 -8
- package/inc/util/system/context_i686.h +0 -9
- package/inc/util/system/context_x86.h +0 -12
- package/inc/util/system/context_x86_64.h +0 -7
- package/inc/util/system/cpu_id.h +0 -159
- package/inc/util/system/daemon.h +0 -28
- package/inc/util/system/datetime.h +0 -98
- package/inc/util/system/defaults.h +0 -149
- package/inc/util/system/demangle.h +0 -5
- package/inc/util/system/demangle_impl.h +0 -23
- package/inc/util/system/direct_io.h +0 -71
- package/inc/util/system/dynlib.h +0 -119
- package/inc/util/system/env.h +0 -32
- package/inc/util/system/error.h +0 -95
- package/inc/util/system/event.h +0 -122
- package/inc/util/system/execpath.h +0 -17
- package/inc/util/system/fasttime.h +0 -6
- package/inc/util/system/fhandle.h +0 -27
- package/inc/util/system/file.h +0 -210
- package/inc/util/system/file_lock.h +0 -34
- package/inc/util/system/filemap.h +0 -383
- package/inc/util/system/flock.h +0 -35
- package/inc/util/system/fs.h +0 -156
- package/inc/util/system/fs_win.h +0 -29
- package/inc/util/system/fstat.h +0 -46
- package/inc/util/system/getpid.h +0 -12
- package/inc/util/system/guard.h +0 -179
- package/inc/util/system/hi_lo.h +0 -139
- package/inc/util/system/hostname.h +0 -10
- package/inc/util/system/hp_timer.h +0 -36
- package/inc/util/system/info.h +0 -12
- package/inc/util/system/interrupt_signals.h +0 -22
- package/inc/util/system/madvise.h +0 -30
- package/inc/util/system/maxlen.h +0 -32
- package/inc/util/system/mem_info.h +0 -18
- package/inc/util/system/mincore.h +0 -38
- package/inc/util/system/mktemp.h +0 -11
- package/inc/util/system/mlock.h +0 -43
- package/inc/util/system/mutex.h +0 -67
- package/inc/util/system/nice.h +0 -3
- package/inc/util/system/pipe.h +0 -90
- package/inc/util/system/platform.h +0 -246
- package/inc/util/system/progname.h +0 -13
- package/inc/util/system/protect.h +0 -25
- package/inc/util/system/rusage.h +0 -26
- package/inc/util/system/rwlock.h +0 -78
- package/inc/util/system/sanitizers.h +0 -122
- package/inc/util/system/sem.h +0 -41
- package/inc/util/system/shellcommand.h +0 -472
- package/inc/util/system/shmat.h +0 -32
- package/inc/util/system/sigset.h +0 -78
- package/inc/util/system/spin_wait.h +0 -10
- package/inc/util/system/spinlock.h +0 -121
- package/inc/util/system/src_location.h +0 -25
- package/inc/util/system/src_root.h +0 -68
- package/inc/util/system/sys_alloc.h +0 -43
- package/inc/util/system/sysstat.h +0 -52
- package/inc/util/system/tempfile.h +0 -34
- package/inc/util/system/thread.h +0 -167
- package/inc/util/system/tls.h +0 -307
- package/inc/util/system/types.h +0 -119
- package/inc/util/system/unaligned_mem.h +0 -67
- package/inc/util/system/user.h +0 -5
- package/inc/util/system/utime.h +0 -6
- package/inc/util/system/valgrind.h +0 -48
- package/inc/util/system/winint.h +0 -43
- package/inc/util/system/yassert.h +0 -121
- package/inc/util/system/yield.h +0 -4
- package/inc/util/thread/factory.h +0 -65
- package/inc/util/thread/fwd.h +0 -30
- package/inc/util/thread/lfqueue.h +0 -406
- package/inc/util/thread/lfstack.h +0 -188
- package/inc/util/thread/pool.h +0 -388
- package/inc/util/thread/singleton.h +0 -42
- package/inc/util/ysafeptr.h +0 -427
- package/inc/util/ysaveload.h +0 -700
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "init.h"
|
|
4
|
-
|
|
5
|
-
#include <util/system/yassert.h>
|
|
6
|
-
#include <util/system/defaults.h>
|
|
7
|
-
#include <util/system/error.h>
|
|
8
|
-
#include <util/stream/output.h>
|
|
9
|
-
#include <util/stream/input.h>
|
|
10
|
-
#include <util/generic/ptr.h>
|
|
11
|
-
#include <util/generic/yexception.h>
|
|
12
|
-
#include <util/generic/noncopyable.h>
|
|
13
|
-
#include <util/datetime/base.h>
|
|
14
|
-
|
|
15
|
-
#include <cerrno>
|
|
16
|
-
|
|
17
|
-
#ifndef INET_ADDRSTRLEN
|
|
18
|
-
#define INET_ADDRSTRLEN 16
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
#if defined(_unix_)
|
|
22
|
-
#define get_host_error() h_errno
|
|
23
|
-
#elif defined(_win_)
|
|
24
|
-
#pragma comment(lib, "Ws2_32.lib")
|
|
25
|
-
|
|
26
|
-
#if _WIN32_WINNT < 0x0600
|
|
27
|
-
struct pollfd {
|
|
28
|
-
SOCKET fd;
|
|
29
|
-
short events;
|
|
30
|
-
short revents;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
#define POLLIN (1 << 0)
|
|
34
|
-
#define POLLRDNORM (1 << 1)
|
|
35
|
-
#define POLLRDBAND (1 << 2)
|
|
36
|
-
#define POLLPRI (1 << 3)
|
|
37
|
-
#define POLLOUT (1 << 4)
|
|
38
|
-
#define POLLWRNORM (1 << 5)
|
|
39
|
-
#define POLLWRBAND (1 << 6)
|
|
40
|
-
#define POLLERR (1 << 7)
|
|
41
|
-
#define POLLHUP (1 << 8)
|
|
42
|
-
#define POLLNVAL (1 << 9)
|
|
43
|
-
|
|
44
|
-
const char* inet_ntop(int af, const void* src, char* dst, socklen_t size);
|
|
45
|
-
int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept;
|
|
46
|
-
#else
|
|
47
|
-
#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
|
|
48
|
-
#endif
|
|
49
|
-
|
|
50
|
-
int inet_aton(const char* cp, struct in_addr* inp);
|
|
51
|
-
|
|
52
|
-
#define get_host_error() WSAGetLastError()
|
|
53
|
-
|
|
54
|
-
#define SHUT_RD SD_RECEIVE
|
|
55
|
-
#define SHUT_WR SD_SEND
|
|
56
|
-
#define SHUT_RDWR SD_BOTH
|
|
57
|
-
|
|
58
|
-
#define INFTIM (-1)
|
|
59
|
-
#endif
|
|
60
|
-
|
|
61
|
-
template <class T>
|
|
62
|
-
static inline int SetSockOpt(SOCKET s, int level, int optname, T opt) noexcept {
|
|
63
|
-
return setsockopt(s, level, optname, (const char*)&opt, sizeof(opt));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
template <class T>
|
|
67
|
-
static inline int GetSockOpt(SOCKET s, int level, int optname, T& opt) noexcept {
|
|
68
|
-
socklen_t len = sizeof(opt);
|
|
69
|
-
|
|
70
|
-
return getsockopt(s, level, optname, (char*)&opt, &len);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
template <class T>
|
|
74
|
-
static inline void CheckedSetSockOpt(SOCKET s, int level, int optname, T opt, const char* err) {
|
|
75
|
-
if (SetSockOpt<T>(s, level, optname, opt)) {
|
|
76
|
-
ythrow TSystemError() << "setsockopt() failed for " << err;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
template <class T>
|
|
81
|
-
static inline void CheckedGetSockOpt(SOCKET s, int level, int optname, T& opt, const char* err) {
|
|
82
|
-
if (GetSockOpt<T>(s, level, optname, opt)) {
|
|
83
|
-
ythrow TSystemError() << "getsockopt() failed for " << err;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static inline void FixIPv6ListenSocket(SOCKET s) {
|
|
88
|
-
#if defined(IPV6_V6ONLY)
|
|
89
|
-
SetSockOpt(s, IPPROTO_IPV6, IPV6_V6ONLY, 1);
|
|
90
|
-
#else
|
|
91
|
-
(void)s;
|
|
92
|
-
#endif
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
namespace NAddr {
|
|
96
|
-
class IRemoteAddr;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
void SetSocketTimeout(SOCKET s, long timeout);
|
|
100
|
-
void SetSocketTimeout(SOCKET s, long sec, long msec);
|
|
101
|
-
void SetNoDelay(SOCKET s, bool value);
|
|
102
|
-
void SetKeepAlive(SOCKET s);
|
|
103
|
-
void SetLinger(SOCKET s, bool on, unsigned len);
|
|
104
|
-
void SetZeroLinger(SOCKET s);
|
|
105
|
-
void SetKeepAlive(SOCKET s, bool value);
|
|
106
|
-
void SetCloseOnExec(SOCKET s, bool value);
|
|
107
|
-
void SetOutputBuffer(SOCKET s, unsigned value);
|
|
108
|
-
void SetInputBuffer(SOCKET s, unsigned value);
|
|
109
|
-
void SetReusePort(SOCKET s, bool value);
|
|
110
|
-
void ShutDown(SOCKET s, int mode);
|
|
111
|
-
bool GetRemoteAddr(SOCKET s, char* str, socklen_t size);
|
|
112
|
-
size_t GetMaximumSegmentSize(SOCKET s);
|
|
113
|
-
size_t GetMaximumTransferUnit(SOCKET s);
|
|
114
|
-
void SetDeferAccept(SOCKET s);
|
|
115
|
-
void SetSocketToS(SOCKET s, int tos);
|
|
116
|
-
void SetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr, int tos);
|
|
117
|
-
int GetSocketToS(SOCKET s);
|
|
118
|
-
int GetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr);
|
|
119
|
-
void SetTcpFastOpen(SOCKET s, int qlen);
|
|
120
|
-
/**
|
|
121
|
-
* Useful for keep-alive connections.
|
|
122
|
-
**/
|
|
123
|
-
bool IsNotSocketClosedByOtherSide(SOCKET s);
|
|
124
|
-
/**
|
|
125
|
-
* Determines whether connection on socket is local (same machine) or not.
|
|
126
|
-
**/
|
|
127
|
-
bool HasLocalAddress(SOCKET socket);
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Runtime check if current kernel supports SO_REUSEPORT option.
|
|
131
|
-
**/
|
|
132
|
-
extern "C" bool IsReusePortAvailable();
|
|
133
|
-
|
|
134
|
-
bool IsNonBlock(SOCKET fd);
|
|
135
|
-
void SetNonBlock(SOCKET fd, bool nonBlock = true);
|
|
136
|
-
|
|
137
|
-
struct addrinfo;
|
|
138
|
-
|
|
139
|
-
class TNetworkResolutionError: public yexception {
|
|
140
|
-
public:
|
|
141
|
-
// @param error error code (EAI_XXX) returned by getaddrinfo or getnameinfo (not errno)
|
|
142
|
-
TNetworkResolutionError(int error);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
struct TUnixSocketPath {
|
|
146
|
-
TString Path;
|
|
147
|
-
|
|
148
|
-
// Constructor for create unix domain socket path from string with path in filesystem
|
|
149
|
-
// TUnixSocketPath("/tmp/unixsocket") -> "/tmp/unixsocket"
|
|
150
|
-
explicit TUnixSocketPath(const TString& path)
|
|
151
|
-
: Path(path)
|
|
152
|
-
{}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
class TNetworkAddress {
|
|
156
|
-
friend class TSocket;
|
|
157
|
-
|
|
158
|
-
public:
|
|
159
|
-
class TIterator {
|
|
160
|
-
public:
|
|
161
|
-
inline TIterator(struct addrinfo* begin)
|
|
162
|
-
: C_(begin)
|
|
163
|
-
{
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
inline void Next() noexcept {
|
|
167
|
-
C_ = C_->ai_next;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
inline TIterator operator++(int) noexcept {
|
|
171
|
-
TIterator old(*this);
|
|
172
|
-
|
|
173
|
-
Next();
|
|
174
|
-
|
|
175
|
-
return old;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
inline TIterator& operator++() noexcept {
|
|
179
|
-
Next();
|
|
180
|
-
|
|
181
|
-
return *this;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
friend inline bool operator==(const TIterator& l, const TIterator& r) noexcept {
|
|
185
|
-
return l.C_ == r.C_;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
friend inline bool operator!=(const TIterator& l, const TIterator& r) noexcept {
|
|
189
|
-
return !(l == r);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
inline struct addrinfo& operator*() const noexcept {
|
|
193
|
-
return *C_;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
inline struct addrinfo* operator->() const noexcept {
|
|
197
|
-
return C_;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private:
|
|
201
|
-
struct addrinfo* C_;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
TNetworkAddress(ui16 port);
|
|
205
|
-
TNetworkAddress(const TString& host, ui16 port);
|
|
206
|
-
TNetworkAddress(const TString& host, ui16 port, int flags);
|
|
207
|
-
TNetworkAddress(const TUnixSocketPath& unixSocketPath, int flags = 0);
|
|
208
|
-
~TNetworkAddress();
|
|
209
|
-
|
|
210
|
-
inline TIterator Begin() const noexcept {
|
|
211
|
-
return TIterator(Info());
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
inline TIterator End() const noexcept {
|
|
215
|
-
return TIterator(nullptr);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
private:
|
|
219
|
-
struct addrinfo* Info() const noexcept;
|
|
220
|
-
|
|
221
|
-
private:
|
|
222
|
-
class TImpl;
|
|
223
|
-
TSimpleIntrusivePtr<TImpl> Impl_;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
class TSocket;
|
|
227
|
-
|
|
228
|
-
class TSocketHolder: public TMoveOnly {
|
|
229
|
-
public:
|
|
230
|
-
inline TSocketHolder()
|
|
231
|
-
: Fd_(INVALID_SOCKET)
|
|
232
|
-
{
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
inline TSocketHolder(SOCKET fd)
|
|
236
|
-
: Fd_(fd)
|
|
237
|
-
{
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
inline TSocketHolder(TSocketHolder&& other) noexcept {
|
|
241
|
-
Fd_ = other.Fd_;
|
|
242
|
-
other.Fd_ = INVALID_SOCKET;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
inline TSocketHolder& operator=(TSocketHolder&& other) noexcept {
|
|
246
|
-
Close();
|
|
247
|
-
Swap(other);
|
|
248
|
-
|
|
249
|
-
return *this;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
inline ~TSocketHolder() {
|
|
253
|
-
Close();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
inline SOCKET Release() noexcept {
|
|
257
|
-
SOCKET ret = Fd_;
|
|
258
|
-
Fd_ = INVALID_SOCKET;
|
|
259
|
-
return ret;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
void Close() noexcept;
|
|
263
|
-
|
|
264
|
-
inline void ShutDown(int mode) const {
|
|
265
|
-
::ShutDown(Fd_, mode);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
inline void Swap(TSocketHolder& r) noexcept {
|
|
269
|
-
DoSwap(Fd_, r.Fd_);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
inline bool Closed() const noexcept {
|
|
273
|
-
return Fd_ == INVALID_SOCKET;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
inline operator SOCKET() const noexcept {
|
|
277
|
-
return Fd_;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private:
|
|
281
|
-
SOCKET Fd_;
|
|
282
|
-
|
|
283
|
-
// do not allow construction of TSocketHolder from TSocket
|
|
284
|
-
TSocketHolder(const TSocket& fd);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
class TSocket {
|
|
288
|
-
public:
|
|
289
|
-
using TPart = IOutputStream::TPart;
|
|
290
|
-
|
|
291
|
-
class TOps {
|
|
292
|
-
public:
|
|
293
|
-
inline TOps() noexcept = default;
|
|
294
|
-
virtual ~TOps() = default;
|
|
295
|
-
|
|
296
|
-
virtual ssize_t Send(SOCKET fd, const void* data, size_t len) = 0;
|
|
297
|
-
virtual ssize_t Recv(SOCKET fd, void* buf, size_t len) = 0;
|
|
298
|
-
virtual ssize_t SendV(SOCKET fd, const TPart* parts, size_t count) = 0;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
TSocket();
|
|
302
|
-
TSocket(SOCKET fd);
|
|
303
|
-
TSocket(SOCKET fd, TOps* ops);
|
|
304
|
-
TSocket(const TNetworkAddress& addr);
|
|
305
|
-
TSocket(const TNetworkAddress& addr, const TDuration& timeOut);
|
|
306
|
-
TSocket(const TNetworkAddress& addr, const TInstant& deadLine);
|
|
307
|
-
|
|
308
|
-
~TSocket();
|
|
309
|
-
|
|
310
|
-
template <class T>
|
|
311
|
-
inline void SetSockOpt(int level, int optname, T opt) {
|
|
312
|
-
CheckedSetSockOpt(Fd(), level, optname, opt, "TSocket");
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
inline void SetSocketTimeout(long timeout) {
|
|
316
|
-
::SetSocketTimeout(Fd(), timeout);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
inline void SetSocketTimeout(long sec, long msec) {
|
|
320
|
-
::SetSocketTimeout(Fd(), sec, msec);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
inline void SetNoDelay(bool value) {
|
|
324
|
-
::SetNoDelay(Fd(), value);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
inline void SetLinger(bool on, unsigned len) {
|
|
328
|
-
::SetLinger(Fd(), on, len);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
inline void SetZeroLinger() {
|
|
332
|
-
::SetZeroLinger(Fd());
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
inline void SetKeepAlive(bool value) {
|
|
336
|
-
::SetKeepAlive(Fd(), value);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
inline void SetOutputBuffer(unsigned value) {
|
|
340
|
-
::SetOutputBuffer(Fd(), value);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
inline void SetInputBuffer(unsigned value) {
|
|
344
|
-
::SetInputBuffer(Fd(), value);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
inline size_t MaximumSegmentSize() const {
|
|
348
|
-
return GetMaximumSegmentSize(Fd());
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
inline size_t MaximumTransferUnit() const {
|
|
352
|
-
return GetMaximumTransferUnit(Fd());
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
inline void ShutDown(int mode) const {
|
|
356
|
-
::ShutDown(Fd(), mode);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
void Close();
|
|
360
|
-
|
|
361
|
-
ssize_t Send(const void* data, size_t len);
|
|
362
|
-
ssize_t Recv(void* buf, size_t len);
|
|
363
|
-
|
|
364
|
-
/*
|
|
365
|
-
* scatter/gather io
|
|
366
|
-
*/
|
|
367
|
-
ssize_t SendV(const TPart* parts, size_t count);
|
|
368
|
-
|
|
369
|
-
inline operator SOCKET() const noexcept {
|
|
370
|
-
return Fd();
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
private:
|
|
374
|
-
SOCKET Fd() const noexcept;
|
|
375
|
-
|
|
376
|
-
private:
|
|
377
|
-
class TImpl;
|
|
378
|
-
TSimpleIntrusivePtr<TImpl> Impl_;
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
class TSocketInput: public IInputStream {
|
|
382
|
-
public:
|
|
383
|
-
TSocketInput(const TSocket& s) noexcept;
|
|
384
|
-
~TSocketInput() override;
|
|
385
|
-
|
|
386
|
-
TSocketInput(TSocketInput&&) noexcept = default;
|
|
387
|
-
TSocketInput& operator=(TSocketInput&&) noexcept = default;
|
|
388
|
-
|
|
389
|
-
const TSocket& GetSocket() const noexcept {
|
|
390
|
-
return S_;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
private:
|
|
394
|
-
size_t DoRead(void* buf, size_t len) override;
|
|
395
|
-
|
|
396
|
-
private:
|
|
397
|
-
TSocket S_;
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
class TSocketOutput: public IOutputStream {
|
|
401
|
-
public:
|
|
402
|
-
TSocketOutput(const TSocket& s) noexcept;
|
|
403
|
-
~TSocketOutput() override;
|
|
404
|
-
|
|
405
|
-
TSocketOutput(TSocketOutput&&) noexcept = default;
|
|
406
|
-
TSocketOutput& operator=(TSocketOutput&&) noexcept = default;
|
|
407
|
-
|
|
408
|
-
const TSocket& GetSocket() const noexcept {
|
|
409
|
-
return S_;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
private:
|
|
413
|
-
void DoWrite(const void* buf, size_t len) override;
|
|
414
|
-
void DoWriteV(const TPart* parts, size_t count) override;
|
|
415
|
-
|
|
416
|
-
private:
|
|
417
|
-
TSocket S_;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
//return -(error code) if error occured, or number of ready fds
|
|
421
|
-
ssize_t PollD(struct pollfd fds[], nfds_t nfds, const TInstant& deadLine) noexcept;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <util/system/defaults.h>
|
|
4
|
-
#include <util/system/yassert.h>
|
|
5
|
-
|
|
6
|
-
namespace NPrivate {
|
|
7
|
-
constexpr double ToRandReal1(const ui32 x) noexcept {
|
|
8
|
-
return x * (double)(1.0 / 4294967295.0);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
constexpr double ToRandReal2(const ui32 x) noexcept {
|
|
12
|
-
return x * (double)(1.0 / 4294967296.0);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
constexpr double ToRandReal3(const ui32 x) noexcept {
|
|
16
|
-
return ((double)x + 0.5) * (double)(1.0 / 4294967296.0);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
constexpr double ToRandReal1(const ui64 x) noexcept {
|
|
20
|
-
return (x >> 11) * (double)(1.0 / 9007199254740991.0);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
constexpr double ToRandReal2(const ui64 x) noexcept {
|
|
24
|
-
return (x >> 11) * (double)(1.0 / 9007199254740992.0);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
constexpr double ToRandReal3(const ui64 x) noexcept {
|
|
28
|
-
return ((x >> 12) + 0.5) * (double)(1.0 / 4503599627370496.0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
constexpr double ToRandReal4(const ui64 x) noexcept {
|
|
32
|
-
return double(x * (double)(1.0 / 18446744073709551616.0L));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
template <class T>
|
|
36
|
-
static inline ui64 ToRand64(T&& rng, ui32 x) noexcept {
|
|
37
|
-
return ((ui64)x) | (((ui64)rng.GenRand()) << 32);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
template <class T>
|
|
41
|
-
static constexpr ui64 ToRand64(T&&, ui64 x) noexcept {
|
|
42
|
-
return x;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/*
|
|
46
|
-
* return value in range [0, max) from any generator
|
|
47
|
-
*/
|
|
48
|
-
template <class T, class TRandGen>
|
|
49
|
-
static T GenUniform(T max, TRandGen&& gen) {
|
|
50
|
-
Y_VERIFY(max > 0, "Invalid random number range [0, 0)");
|
|
51
|
-
|
|
52
|
-
const T randmax = gen.RandMax() - gen.RandMax() % max;
|
|
53
|
-
T rand;
|
|
54
|
-
|
|
55
|
-
while ((rand = gen.GenRand()) >= randmax) {
|
|
56
|
-
/* no-op */
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return rand % max;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
template <class TRandType, class T>
|
|
64
|
-
struct TCommonRNG {
|
|
65
|
-
using TResult = TRandType;
|
|
66
|
-
using result_type = TRandType;
|
|
67
|
-
|
|
68
|
-
inline T& Engine() noexcept {
|
|
69
|
-
return static_cast<T&>(*this);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static constexpr TResult _Min = TResult(0);
|
|
73
|
-
static constexpr TResult _Max = TResult(-1);
|
|
74
|
-
|
|
75
|
-
static constexpr TResult RandMax() noexcept {
|
|
76
|
-
return _Max;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static constexpr TResult RandMin() noexcept {
|
|
80
|
-
return _Min;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/* generates uniformly distributed random number on [0, t) interval */
|
|
84
|
-
inline TResult Uniform(TResult t) noexcept {
|
|
85
|
-
return ::NPrivate::GenUniform(t, Engine());
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* generates uniformly distributed random number on [f, t) interval */
|
|
89
|
-
inline TResult Uniform(TResult f, TResult t) noexcept {
|
|
90
|
-
return f + Uniform(t - f);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* generates 64-bit random number for current(may be 32 bit) rng */
|
|
94
|
-
inline ui64 GenRand64() noexcept {
|
|
95
|
-
return ::NPrivate::ToRand64(Engine(), Engine().GenRand());
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* generates a random number on [0, 1]-real-interval */
|
|
99
|
-
inline double GenRandReal1() noexcept {
|
|
100
|
-
return ::NPrivate::ToRandReal1(Engine().GenRand());
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/* generates a random number on [0, 1)-real-interval */
|
|
104
|
-
inline double GenRandReal2() noexcept {
|
|
105
|
-
return ::NPrivate::ToRandReal2(Engine().GenRand());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* generates a random number on (0, 1)-real-interval */
|
|
109
|
-
inline double GenRandReal3() noexcept {
|
|
110
|
-
return ::NPrivate::ToRandReal3(Engine().GenRand());
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/* generates a random number on [0, 1) with 53-bit resolution */
|
|
114
|
-
inline double GenRandReal4() noexcept {
|
|
115
|
-
return ::NPrivate::ToRandReal4(Engine().GenRand64());
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
//compatibility stuff
|
|
119
|
-
inline TResult operator()() noexcept {
|
|
120
|
-
return Engine().GenRand();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static constexpr TResult max() noexcept {
|
|
124
|
-
return T::RandMax();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static constexpr TResult min() noexcept {
|
|
128
|
-
return T::RandMin();
|
|
129
|
-
}
|
|
130
|
-
};
|
package/inc/util/random/easy.h
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "random.h"
|
|
4
|
-
|
|
5
|
-
namespace NPrivate {
|
|
6
|
-
struct TRandom {
|
|
7
|
-
inline operator unsigned char() {
|
|
8
|
-
return RandomNumber<unsigned char>();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
inline operator unsigned short() {
|
|
12
|
-
return RandomNumber<unsigned short>();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
inline operator unsigned int() {
|
|
16
|
-
return RandomNumber<unsigned int>();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
inline operator unsigned long() {
|
|
20
|
-
return RandomNumber<unsigned long>();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
inline operator unsigned long long() {
|
|
24
|
-
return RandomNumber<unsigned long long>();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
inline operator bool() {
|
|
28
|
-
return RandomNumber<bool>();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
inline operator float() {
|
|
32
|
-
return RandomNumber<float>();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
inline operator double() {
|
|
36
|
-
return RandomNumber<double>();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
inline operator long double() {
|
|
40
|
-
return RandomNumber<long double>();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static inline ::NPrivate::TRandom Random() noexcept {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
class TBuffer;
|
|
4
|
-
class IInputStream;
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* fast entropy pool, based on good prng, can lock for some time
|
|
8
|
-
* initialized with some bits from system entropy pool
|
|
9
|
-
* think as /dev/urandom replacement
|
|
10
|
-
*/
|
|
11
|
-
IInputStream& EntropyPool();
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* fast(non-blocking) entropy pool, useful for seeding PRNGs
|
|
15
|
-
*/
|
|
16
|
-
IInputStream& Seed();
|
|
17
|
-
|
|
18
|
-
/*
|
|
19
|
-
* Re-initialize entropy pool - useful after forking in multi-process programs.
|
|
20
|
-
*/
|
|
21
|
-
void ResetEntropyPool();
|
package/inc/util/random/fast.h
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "lcg_engine.h"
|
|
4
|
-
#include "common_ops.h"
|
|
5
|
-
|
|
6
|
-
#include <util/generic/bitops.h>
|
|
7
|
-
#include <util/system/platform.h>
|
|
8
|
-
|
|
9
|
-
// based on http://www.pcg-random.org/. See T*FastRng* family below.
|
|
10
|
-
|
|
11
|
-
struct TPCGMixer {
|
|
12
|
-
static inline ui32 Mix(ui64 x) noexcept {
|
|
13
|
-
const ui32 xorshifted = ((x >> 18u) ^ x) >> 27u;
|
|
14
|
-
const ui32 rot = x >> 59u;
|
|
15
|
-
|
|
16
|
-
return RotateBitsRight(xorshifted, rot);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
using TFastRng32Base = TLcgRngBase<TLcgIterator<ui64, ULL(6364136223846793005)>, TPCGMixer>;
|
|
21
|
-
using TReallyFastRng32Base = TLcgRngBase<TFastLcgIterator<ui64, ULL(6364136223846793005), ULL(1)>, TPCGMixer>;
|
|
22
|
-
|
|
23
|
-
class IInputStream;
|
|
24
|
-
|
|
25
|
-
struct TFastRng32: public TCommonRNG<ui32, TFastRng32>, public TFastRng32Base {
|
|
26
|
-
inline TFastRng32(ui64 seed, ui32 seq)
|
|
27
|
-
: TFastRng32Base(seed, seq)
|
|
28
|
-
{
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
TFastRng32(IInputStream& entropy);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// faster than TFastRng32, but have only one possible stream sequence
|
|
35
|
-
struct TReallyFastRng32: public TCommonRNG<ui32, TReallyFastRng32>, public TReallyFastRng32Base {
|
|
36
|
-
inline TReallyFastRng32(ui64 seed)
|
|
37
|
-
: TReallyFastRng32Base(seed)
|
|
38
|
-
{
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
TReallyFastRng32(IInputStream& entropy);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
class TFastRng64: public TCommonRNG<ui64, TFastRng64> {
|
|
45
|
-
public:
|
|
46
|
-
struct TArgs {
|
|
47
|
-
TArgs(ui64 seed) noexcept;
|
|
48
|
-
TArgs(IInputStream& entropy);
|
|
49
|
-
|
|
50
|
-
ui64 Seed1;
|
|
51
|
-
ui64 Seed2;
|
|
52
|
-
ui32 Seq1;
|
|
53
|
-
ui32 Seq2;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept;
|
|
57
|
-
|
|
58
|
-
/*
|
|
59
|
-
* simplify constructions like
|
|
60
|
-
* TFastRng64 rng(17);
|
|
61
|
-
* TFastRng64 rng(Seek()); //from any IInputStream
|
|
62
|
-
*/
|
|
63
|
-
inline TFastRng64(const TArgs& args) noexcept
|
|
64
|
-
: TFastRng64(args.Seed1, args.Seq1, args.Seed2, args.Seq2)
|
|
65
|
-
{
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
inline ui64 GenRand() noexcept {
|
|
69
|
-
const ui64 x = R1_.GenRand();
|
|
70
|
-
const ui64 y = R2_.GenRand();
|
|
71
|
-
|
|
72
|
-
return (x << 32) | y;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
inline void Advance(ui64 delta) noexcept {
|
|
76
|
-
R1_.Advance(delta);
|
|
77
|
-
R2_.Advance(delta);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private:
|
|
81
|
-
TFastRng32Base R1_;
|
|
82
|
-
TFastRng32Base R2_;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
namespace NPrivate {
|
|
86
|
-
template <typename T>
|
|
87
|
-
struct TFastRngTraits;
|
|
88
|
-
|
|
89
|
-
template <>
|
|
90
|
-
struct TFastRngTraits<ui32> {
|
|
91
|
-
using TResult = TReallyFastRng32;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
template <>
|
|
95
|
-
struct TFastRngTraits<ui64> {
|
|
96
|
-
using TResult = TFastRng64;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
template <typename T>
|
|
101
|
-
using TFastRng = typename ::NPrivate::TFastRngTraits<T>::TResult;
|