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,171 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "typetraits.h"
|
|
4
|
-
#include "yexception.h"
|
|
5
|
-
|
|
6
|
-
#include <utility>
|
|
7
|
-
#include <type_traits>
|
|
8
|
-
|
|
9
|
-
template <class... Ts>
|
|
10
|
-
class TVariant;
|
|
11
|
-
|
|
12
|
-
class TWrongVariantError: public yexception {};
|
|
13
|
-
|
|
14
|
-
namespace NVariant {
|
|
15
|
-
template <size_t I, class T>
|
|
16
|
-
struct TIndexedType {
|
|
17
|
-
static constexpr size_t value = I;
|
|
18
|
-
using type = T;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
template <class, class... Ts>
|
|
22
|
-
struct TIndexedTypesImpl;
|
|
23
|
-
|
|
24
|
-
template <std::size_t... Is, class... Ts>
|
|
25
|
-
struct TIndexedTypesImpl<std::index_sequence<Is...>, Ts...> {
|
|
26
|
-
struct type : TIndexedType<Is, Ts>... {};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
template <class... Ts>
|
|
30
|
-
using TIndexedTypes = typename TIndexedTypesImpl<std::index_sequence_for<Ts...>, Ts...>::type;
|
|
31
|
-
|
|
32
|
-
template <size_t I, class T>
|
|
33
|
-
constexpr auto GetIndexedType(TIndexedType<I, T> t) {
|
|
34
|
-
return t;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
template <size_t I, class... Ts>
|
|
38
|
-
struct TTypeByIndex {
|
|
39
|
-
using TTypeImpl = decltype(GetIndexedType<I>(TIndexedTypes<Ts...>{})); // MSVC workaround
|
|
40
|
-
using type = typename TTypeImpl::type;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
template <size_t I, class... Ts>
|
|
44
|
-
using TTypeByIndexType = typename TTypeByIndex<I, Ts...>::type;
|
|
45
|
-
|
|
46
|
-
template <size_t I, class V>
|
|
47
|
-
struct TAlternative;
|
|
48
|
-
|
|
49
|
-
template <size_t I, class... Ts>
|
|
50
|
-
struct TAlternative<I, TVariant<Ts...>> {
|
|
51
|
-
using type = TTypeByIndexType<I, Ts...>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
template <size_t I, class V>
|
|
55
|
-
using TAlternativeType = typename TAlternative<I, V>::type;
|
|
56
|
-
|
|
57
|
-
template <class V>
|
|
58
|
-
struct TSize;
|
|
59
|
-
|
|
60
|
-
template <class... Ts>
|
|
61
|
-
struct TSize<TVariant<Ts...>> : std::integral_constant<size_t, sizeof...(Ts)> {};
|
|
62
|
-
|
|
63
|
-
struct TVariantAccessor {
|
|
64
|
-
template <size_t I, class... Ts>
|
|
65
|
-
static TAlternativeType<I, TVariant<Ts...>>& Get(TVariant<Ts...>& v);
|
|
66
|
-
|
|
67
|
-
template <size_t I, class... Ts>
|
|
68
|
-
static const TAlternativeType<I, TVariant<Ts...>>& Get(const TVariant<Ts...>& v);
|
|
69
|
-
|
|
70
|
-
template <size_t I, class... Ts>
|
|
71
|
-
static TAlternativeType<I, TVariant<Ts...>>&& Get(TVariant<Ts...>&& v);
|
|
72
|
-
|
|
73
|
-
template <size_t I, class... Ts>
|
|
74
|
-
static const TAlternativeType<I, TVariant<Ts...>>&& Get(const TVariant<Ts...>&& v);
|
|
75
|
-
|
|
76
|
-
template <class... Ts>
|
|
77
|
-
static constexpr size_t Index(const TVariant<Ts...>& v) noexcept;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
constexpr size_t T_NPOS = -1;
|
|
81
|
-
|
|
82
|
-
template <class X, class... Ts>
|
|
83
|
-
constexpr size_t IndexOfImpl() {
|
|
84
|
-
bool bs[] = {std::is_same<X, Ts>::value...};
|
|
85
|
-
for (size_t i = 0; i < sizeof...(Ts); ++i) {
|
|
86
|
-
if (bs[i]) {
|
|
87
|
-
return i;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return T_NPOS;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
template <class X, class... Ts>
|
|
94
|
-
struct TIndexOf : std::integral_constant<size_t, IndexOfImpl<X, Ts...>()> {};
|
|
95
|
-
|
|
96
|
-
template <class X, class V>
|
|
97
|
-
struct TAlternativeIndex;
|
|
98
|
-
|
|
99
|
-
template <class X, class... Ts>
|
|
100
|
-
struct TAlternativeIndex<X, TVariant<Ts...>> : TIndexOf<X, Ts...> {};
|
|
101
|
-
|
|
102
|
-
template <class... Ts>
|
|
103
|
-
struct TTypeTraits {
|
|
104
|
-
using TNoRefs = TConjunction<TNegation<std::is_reference<Ts>>...>;
|
|
105
|
-
using TNoVoids = TConjunction<TNegation<std::is_same<Ts, void>>...>;
|
|
106
|
-
using TNoArrays = TConjunction<TNegation<std::is_array<Ts>>...>;
|
|
107
|
-
using TNotEmpty = std::integral_constant<bool, (sizeof...(Ts) > 0)>;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
template <class FRef, class VRef, size_t I = 0>
|
|
111
|
-
using TReturnType = decltype(
|
|
112
|
-
std::declval<FRef>()(TVariantAccessor::Get<I>(std::declval<VRef>())));
|
|
113
|
-
|
|
114
|
-
template <class FRef, class VRef, size_t... Is>
|
|
115
|
-
constexpr bool CheckReturnTypes(std::index_sequence<Is...>) {
|
|
116
|
-
using R = TReturnType<FRef, VRef>;
|
|
117
|
-
return TConjunction<std::is_same<R, TReturnType<FRef, VRef, Is>>...>::value;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
template <class ReturnType, size_t I, class FRef, class VRef>
|
|
121
|
-
ReturnType VisitImplImpl(FRef f, VRef v) {
|
|
122
|
-
return std::forward<FRef>(f)(TVariantAccessor::Get<I>(std::forward<VRef>(v)));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
template <class ReturnType, class FRef, class VRef>
|
|
126
|
-
ReturnType VisitImplFail(FRef, VRef) {
|
|
127
|
-
throw TWrongVariantError{};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
template <class F, class V, size_t... Is>
|
|
131
|
-
decltype(auto) VisitImpl(F&& f, V&& v, std::index_sequence<Is...>) {
|
|
132
|
-
using FRef = decltype(std::forward<F>(f));
|
|
133
|
-
using VRef = decltype(std::forward<V>(v));
|
|
134
|
-
using ReturnType = TReturnType<FRef, VRef>;
|
|
135
|
-
using LambdaType = ReturnType (*)(FRef, VRef);
|
|
136
|
-
static constexpr LambdaType handlers[] = {
|
|
137
|
-
VisitImplImpl<ReturnType, Is, FRef, VRef>...,
|
|
138
|
-
VisitImplFail<ReturnType, FRef, VRef>};
|
|
139
|
-
return handlers[TVariantAccessor::Index(v)](std::forward<F>(f), std::forward<V>(v));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
template <class F, class V>
|
|
143
|
-
void VisitWrapForVoid(F&& f, V&& v, std::true_type) {
|
|
144
|
-
// We need to make special wrapper when return type equals void
|
|
145
|
-
auto l = [&](auto&& x) {
|
|
146
|
-
std::forward<F>(f)(std::forward<decltype(x)>(x));
|
|
147
|
-
return 0;
|
|
148
|
-
};
|
|
149
|
-
VisitImpl(l, std::forward<V>(v), std::make_index_sequence<TSize<std::decay_t<V>>::value>{});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
template <class F, class V>
|
|
153
|
-
decltype(auto) VisitWrapForVoid(F&& f, V&& v, std::false_type) {
|
|
154
|
-
return VisitImpl(std::forward<F>(f),
|
|
155
|
-
std::forward<V>(v),
|
|
156
|
-
std::make_index_sequence<TSize<std::decay_t<V>>::value>{});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Can be simplified with c++17: IGNIETFERRO-982
|
|
160
|
-
template <class Ret, class F, class T, class U>
|
|
161
|
-
std::enable_if_t<std::is_same<std::decay_t<T>, std::decay_t<U>>::value,
|
|
162
|
-
Ret> CallIfSame(F f, T&& a, U&& b) {
|
|
163
|
-
return f(std::forward<T>(a), std::forward<U>(b));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
template <class Ret, class F, class T, class U>
|
|
167
|
-
std::enable_if_t<!std::is_same<std::decay_t<T>, std::decay_t<U>>::value,
|
|
168
|
-
Ret> CallIfSame(F, T&&, U&&) { // Will never be called
|
|
169
|
-
Y_FAIL();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "fwd.h"
|
|
4
|
-
#include "reserve.h"
|
|
5
|
-
|
|
6
|
-
#include <util/memory/alloc.h>
|
|
7
|
-
|
|
8
|
-
#include <vector>
|
|
9
|
-
#include <initializer_list>
|
|
10
|
-
|
|
11
|
-
template <class T, class A>
|
|
12
|
-
class TVector: public std::vector<T, TReboundAllocator<A, T>> {
|
|
13
|
-
public:
|
|
14
|
-
using TBase = std::vector<T, TReboundAllocator<A, T>>;
|
|
15
|
-
using TSelf = TVector<T, A>;
|
|
16
|
-
using size_type = typename TBase::size_type;
|
|
17
|
-
|
|
18
|
-
inline TVector()
|
|
19
|
-
: TBase()
|
|
20
|
-
{
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
inline TVector(const typename TBase::allocator_type& a)
|
|
24
|
-
: TBase(a)
|
|
25
|
-
{
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
inline explicit TVector(::NDetail::TReserveTag rt)
|
|
29
|
-
: TBase()
|
|
30
|
-
{
|
|
31
|
-
this->reserve(rt.Capacity);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
inline explicit TVector(::NDetail::TReserveTag rt, const typename TBase::allocator_type& a)
|
|
35
|
-
: TBase(a)
|
|
36
|
-
{
|
|
37
|
-
this->reserve(rt.Capacity);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
inline explicit TVector(size_type count)
|
|
41
|
-
: TBase(count)
|
|
42
|
-
{
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
inline explicit TVector(size_type count, const typename TBase::allocator_type& a)
|
|
46
|
-
: TBase(count, a)
|
|
47
|
-
{
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
inline TVector(size_type count, const T& val)
|
|
51
|
-
: TBase(count, val)
|
|
52
|
-
{
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
inline TVector(size_type count, const T& val, const typename TBase::allocator_type& a)
|
|
56
|
-
: TBase(count, val, a)
|
|
57
|
-
{
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
inline TVector(std::initializer_list<T> il)
|
|
61
|
-
: TBase(il)
|
|
62
|
-
{
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
inline TVector(std::initializer_list<T> il, const typename TBase::allocator_type& a)
|
|
66
|
-
: TBase(il, a)
|
|
67
|
-
{
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
inline TVector(const TSelf& src)
|
|
71
|
-
: TBase(src)
|
|
72
|
-
{
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
inline TVector(TSelf&& src) noexcept
|
|
76
|
-
: TBase(std::forward<TSelf>(src))
|
|
77
|
-
{
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
template <class TIter>
|
|
81
|
-
inline TVector(TIter first, TIter last)
|
|
82
|
-
: TBase(first, last)
|
|
83
|
-
{
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
inline TSelf& operator=(const TSelf& src) {
|
|
87
|
-
TBase::operator=(src);
|
|
88
|
-
return *this;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
inline TSelf& operator=(TSelf&& src) noexcept {
|
|
92
|
-
TBase::operator=(std::forward<TSelf>(src));
|
|
93
|
-
return *this;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
inline TSelf& operator=(std::initializer_list<T> il) {
|
|
97
|
-
this->assign(il.begin(), il.end());
|
|
98
|
-
return *this;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
inline explicit operator bool() const noexcept {
|
|
102
|
-
return !this->empty();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
Y_PURE_FUNCTION
|
|
106
|
-
inline bool empty() const noexcept {
|
|
107
|
-
return TBase::empty();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
inline yssize_t ysize() const noexcept {
|
|
111
|
-
return (yssize_t)TBase::size();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
inline void crop(size_type size) {
|
|
115
|
-
if (this->size() > size) {
|
|
116
|
-
this->erase(this->begin() + size, this->end());
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "typetraits.h"
|
|
4
|
-
#include "utility.h"
|
|
5
|
-
#include <util/system/yassert.h>
|
|
6
|
-
#include <iterator>
|
|
7
|
-
|
|
8
|
-
/** @file
|
|
9
|
-
* Some similar for python xrange(): https://docs.python.org/2/library/functions.html#xrange
|
|
10
|
-
* Discussion: https://clubs.at.yandex-team.ru/arcadia/6124
|
|
11
|
-
*
|
|
12
|
-
* Example usage:
|
|
13
|
-
* for (auto i: xrange(MyVector.size())) { // instead for (size_t i = 0; i < MyVector.size(); ++i)
|
|
14
|
-
* DoSomething(i, MyVector[i]);
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* TVector<int> arithmeticSeq = xrange(10); // instead: TVector<int> arithmeticSeq; for(size_t i = 0; i < 10; ++i) { arithmeticSeq.push_back(i); }
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
namespace NPrivate {
|
|
22
|
-
template <typename T>
|
|
23
|
-
class TSimpleXRange {
|
|
24
|
-
using TDiff = decltype(T() - T());
|
|
25
|
-
|
|
26
|
-
public:
|
|
27
|
-
constexpr TSimpleXRange(T start, T finish) noexcept
|
|
28
|
-
: Start(start)
|
|
29
|
-
, Finish(Max(start, finish))
|
|
30
|
-
{
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class TIterator {
|
|
34
|
-
public:
|
|
35
|
-
using value_type = T;
|
|
36
|
-
using difference_type = TDiff;
|
|
37
|
-
using pointer = const T*;
|
|
38
|
-
using reference = const T&;
|
|
39
|
-
using iterator_category = std::random_access_iterator_tag;
|
|
40
|
-
|
|
41
|
-
constexpr TIterator(T value) noexcept
|
|
42
|
-
: Value(value)
|
|
43
|
-
{
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
constexpr T operator*() const noexcept {
|
|
47
|
-
return Value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
constexpr bool operator!=(const TIterator& other) const noexcept {
|
|
51
|
-
return Value != other.Value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
constexpr bool operator==(const TIterator& other) const noexcept {
|
|
55
|
-
return Value == other.Value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
TIterator& operator++() noexcept {
|
|
59
|
-
++Value;
|
|
60
|
-
return *this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
constexpr TDiff operator-(const TIterator& b) const noexcept {
|
|
64
|
-
return Value - b.Value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
template <typename IntType>
|
|
68
|
-
constexpr TIterator operator+(const IntType& b) const noexcept {
|
|
69
|
-
return TIterator(Value + b);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
template <typename IntType>
|
|
73
|
-
TIterator& operator+=(const IntType& b) noexcept {
|
|
74
|
-
Value += b;
|
|
75
|
-
return *this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
template <typename IntType>
|
|
79
|
-
constexpr TIterator operator-(const IntType& b) const noexcept {
|
|
80
|
-
return TIterator(Value - b);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
template <typename IntType>
|
|
84
|
-
TIterator& operator-=(const IntType& b) noexcept {
|
|
85
|
-
Value -= b;
|
|
86
|
-
return *this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
constexpr bool operator<(const TIterator& b) const noexcept {
|
|
90
|
-
return Value < b.Value;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private:
|
|
94
|
-
T Value;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
using value_type = T;
|
|
98
|
-
using iterator = TIterator;
|
|
99
|
-
using const_iterator = TIterator;
|
|
100
|
-
|
|
101
|
-
constexpr TIterator begin() const noexcept {
|
|
102
|
-
return TIterator(Start);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
constexpr TIterator end() const noexcept {
|
|
106
|
-
return TIterator(Finish);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
constexpr T size() const noexcept {
|
|
110
|
-
return Finish - Start;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
template <class Container>
|
|
114
|
-
operator Container() const {
|
|
115
|
-
return Container(begin(), end());
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private:
|
|
119
|
-
T Start;
|
|
120
|
-
T Finish;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
template <typename T>
|
|
124
|
-
class TSteppedXRange {
|
|
125
|
-
using TDiff = decltype(T() - T());
|
|
126
|
-
|
|
127
|
-
public:
|
|
128
|
-
constexpr TSteppedXRange(T start, T finish, TDiff step) noexcept
|
|
129
|
-
: Start_(start)
|
|
130
|
-
, Step_(step)
|
|
131
|
-
, Finish_(CalcRealFinish(Start_, finish, Step_))
|
|
132
|
-
{
|
|
133
|
-
static_assert(std::is_integral<T>::value || std::is_pointer<T>::value, "T should be integral type or pointer");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
class TIterator {
|
|
137
|
-
public:
|
|
138
|
-
using value_type = T;
|
|
139
|
-
using difference_type = TDiff;
|
|
140
|
-
using pointer = const T*;
|
|
141
|
-
using reference = const T&;
|
|
142
|
-
using iterator_category = std::random_access_iterator_tag;
|
|
143
|
-
|
|
144
|
-
constexpr TIterator(T value, const TSteppedXRange& parent) noexcept
|
|
145
|
-
: Value_(value)
|
|
146
|
-
, Parent_(&parent)
|
|
147
|
-
{
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
constexpr T operator*() const noexcept {
|
|
151
|
-
return Value_;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
constexpr bool operator!=(const TIterator& other) const noexcept {
|
|
155
|
-
return Value_ != other.Value_;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
constexpr bool operator==(const TIterator& other) const noexcept {
|
|
159
|
-
return Value_ == other.Value_;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
TIterator& operator++() noexcept {
|
|
163
|
-
Value_ += Parent_->Step_;
|
|
164
|
-
return *this;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
constexpr TDiff operator-(const TIterator& b) const noexcept {
|
|
168
|
-
return (Value_ - b.Value_) / Parent_->Step_;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
template <typename IntType>
|
|
172
|
-
constexpr TIterator operator+(const IntType& b) const noexcept {
|
|
173
|
-
return TIterator(*this) += b;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
template <typename IntType>
|
|
177
|
-
TIterator& operator+=(const IntType& b) noexcept {
|
|
178
|
-
Value_ += b * Parent_->Step_;
|
|
179
|
-
return *this;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
template <typename IntType>
|
|
183
|
-
constexpr TIterator operator-(const IntType& b) const noexcept {
|
|
184
|
-
return TIterator(*this) -= b;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
template <typename IntType>
|
|
188
|
-
TIterator& operator-=(const IntType& b) noexcept {
|
|
189
|
-
Value_ -= b * Parent_->Step_;
|
|
190
|
-
return *this;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private:
|
|
194
|
-
T Value_;
|
|
195
|
-
const TSteppedXRange* Parent_;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
using value_type = T;
|
|
199
|
-
using iterator = TIterator;
|
|
200
|
-
using const_iterator = TIterator;
|
|
201
|
-
|
|
202
|
-
constexpr TIterator begin() const noexcept {
|
|
203
|
-
return TIterator(Start_, *this);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
constexpr TIterator end() const noexcept {
|
|
207
|
-
return TIterator(Finish_, *this);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
static T CalcRealFinish(T start, T expFinish, TDiff step) {
|
|
211
|
-
Y_ASSERT(step != 0);
|
|
212
|
-
if (step > 0) {
|
|
213
|
-
if (expFinish > start) {
|
|
214
|
-
return start + step * ((expFinish - 1 - start) / step + 1);
|
|
215
|
-
}
|
|
216
|
-
return start;
|
|
217
|
-
}
|
|
218
|
-
return start - TSteppedXRange<TDiff>::CalcRealFinish(0, start - expFinish, -step);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
constexpr T size() const noexcept {
|
|
222
|
-
return (Finish_ - Start_) / Step_;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
template <class Container>
|
|
226
|
-
operator Container() const {
|
|
227
|
-
return Container(begin(), end());
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private:
|
|
231
|
-
const T Start_;
|
|
232
|
-
const TDiff Step_;
|
|
233
|
-
const T Finish_;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* generate arithmetic progression that starts at start with certain step and stop at finish (not including)
|
|
240
|
-
*
|
|
241
|
-
* @param step must be non-zero
|
|
242
|
-
*/
|
|
243
|
-
template <typename T>
|
|
244
|
-
constexpr ::NPrivate::TSteppedXRange<T> xrange(T start, T finish, decltype(T() - T()) step) noexcept {
|
|
245
|
-
return {start, finish, step};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/// generate sequence [start; finish)
|
|
249
|
-
template <typename T>
|
|
250
|
-
constexpr ::NPrivate::TSimpleXRange<T> xrange(T start, T finish) noexcept {
|
|
251
|
-
return {start, finish};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/// generate sequence [0; finish)
|
|
255
|
-
template <typename T>
|
|
256
|
-
constexpr auto xrange(T finish) noexcept -> decltype(xrange(T(), finish)) {
|
|
257
|
-
return xrange(T(), finish);
|
|
258
|
-
}
|