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,876 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "utility.h"
|
|
4
|
-
|
|
5
|
-
#include <util/system/yassert.h>
|
|
6
|
-
#include <iterator>
|
|
7
|
-
|
|
8
|
-
struct TIntrusiveListDefaultTag { };
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
* two-way linked list
|
|
12
|
-
*/
|
|
13
|
-
template <class T, class Tag = TIntrusiveListDefaultTag>
|
|
14
|
-
class TIntrusiveListItem {
|
|
15
|
-
private:
|
|
16
|
-
using TListItem = TIntrusiveListItem<T, Tag>;
|
|
17
|
-
|
|
18
|
-
public:
|
|
19
|
-
inline TIntrusiveListItem() noexcept
|
|
20
|
-
: Next_(this)
|
|
21
|
-
, Prev_(Next_)
|
|
22
|
-
{
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
inline ~TIntrusiveListItem() {
|
|
26
|
-
Unlink();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public:
|
|
30
|
-
|
|
31
|
-
Y_PURE_FUNCTION
|
|
32
|
-
inline bool Empty() const noexcept {
|
|
33
|
-
return (Prev_ == this) && (Next_ == this);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
inline void Unlink() noexcept {
|
|
37
|
-
if (Empty()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Prev_->SetNext(Next_);
|
|
42
|
-
Next_->SetPrev(Prev_);
|
|
43
|
-
|
|
44
|
-
SetEnd();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
inline void LinkBefore(TListItem* before) noexcept {
|
|
48
|
-
Unlink();
|
|
49
|
-
LinkBeforeNoUnlink(before);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
inline void LinkBeforeNoUnlink(TListItem* before) noexcept {
|
|
53
|
-
TListItem* const after = before->Prev();
|
|
54
|
-
|
|
55
|
-
after->SetNext(this);
|
|
56
|
-
SetPrev(after);
|
|
57
|
-
SetNext(before);
|
|
58
|
-
before->SetPrev(this);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
inline void LinkBefore(TListItem& before) noexcept {
|
|
62
|
-
LinkBefore(&before);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
inline void LinkAfter(TListItem* after) noexcept {
|
|
66
|
-
Unlink();
|
|
67
|
-
LinkBeforeNoUnlink(after->Next());
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
inline void LinkAfter(TListItem& after) noexcept {
|
|
71
|
-
LinkAfter(&after);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public:
|
|
75
|
-
inline TListItem* Prev() noexcept {
|
|
76
|
-
return Prev_;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
inline const TListItem* Prev() const noexcept {
|
|
80
|
-
return Prev_;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
inline TListItem* Next() noexcept {
|
|
84
|
-
return Next_;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
inline const TListItem* Next() const noexcept {
|
|
88
|
-
return Next_;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public:
|
|
92
|
-
inline void SetEnd() noexcept {
|
|
93
|
-
Prev_ = this;
|
|
94
|
-
Next_ = Prev_;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
inline void SetNext(TListItem* item) noexcept {
|
|
98
|
-
Next_ = item;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
inline void SetPrev(TListItem* item) noexcept {
|
|
102
|
-
Prev_ = item;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public:
|
|
106
|
-
inline T* Node() noexcept {
|
|
107
|
-
return static_cast<T*>(this);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
inline const T* Node() const noexcept {
|
|
111
|
-
return static_cast<const T*>(this);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private:
|
|
115
|
-
inline TIntrusiveListItem(const TIntrusiveListItem&) = delete;
|
|
116
|
-
inline TIntrusiveListItem& operator=(const TIntrusiveListItem&) = delete;
|
|
117
|
-
|
|
118
|
-
private:
|
|
119
|
-
TListItem* Next_;
|
|
120
|
-
TListItem* Prev_;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
template <class T, class Tag>
|
|
124
|
-
class TIntrusiveList {
|
|
125
|
-
private:
|
|
126
|
-
using TListItem = TIntrusiveListItem<T, Tag>;
|
|
127
|
-
|
|
128
|
-
template <class TListItem, class TNode>
|
|
129
|
-
class TIteratorBase {
|
|
130
|
-
public:
|
|
131
|
-
using TItem = TListItem;
|
|
132
|
-
using TReference = TNode&;
|
|
133
|
-
using TPointer = TNode*;
|
|
134
|
-
|
|
135
|
-
using iterator_category = std::bidirectional_iterator_tag;
|
|
136
|
-
using difference_type = ptrdiff_t;
|
|
137
|
-
|
|
138
|
-
using value_type = TNode;
|
|
139
|
-
using reference = TReference;
|
|
140
|
-
using pointer = TPointer;
|
|
141
|
-
|
|
142
|
-
inline TIteratorBase() noexcept
|
|
143
|
-
: Item_(nullptr)
|
|
144
|
-
{
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
template <class TListItem_, class TNode_>
|
|
148
|
-
inline TIteratorBase(const TIteratorBase<TListItem_, TNode_>& right) noexcept
|
|
149
|
-
: Item_(right.Item())
|
|
150
|
-
{
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
inline TIteratorBase(TItem* item) noexcept
|
|
154
|
-
: Item_(item)
|
|
155
|
-
{
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
inline TItem* Item() const noexcept {
|
|
159
|
-
return Item_;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
inline void Next() noexcept {
|
|
163
|
-
Item_ = Item_->Next();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
inline void Prev() noexcept {
|
|
167
|
-
Item_ = Item_->Prev();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
template <class TListItem_, class TNode_>
|
|
171
|
-
inline bool operator==(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
|
|
172
|
-
return Item() == right.Item();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
template <class TListItem_, class TNode_>
|
|
176
|
-
inline bool operator!=(const TIteratorBase<TListItem_, TNode_>& right) const noexcept {
|
|
177
|
-
return Item() != right.Item();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
inline TIteratorBase& operator++() noexcept {
|
|
181
|
-
Next();
|
|
182
|
-
|
|
183
|
-
return *this;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
inline TIteratorBase operator++(int) noexcept {
|
|
187
|
-
TIteratorBase ret(*this);
|
|
188
|
-
|
|
189
|
-
Next();
|
|
190
|
-
|
|
191
|
-
return ret;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
inline TIteratorBase& operator--() noexcept {
|
|
195
|
-
Prev();
|
|
196
|
-
|
|
197
|
-
return *this;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
inline TIteratorBase operator--(int) noexcept {
|
|
201
|
-
TIteratorBase ret(*this);
|
|
202
|
-
|
|
203
|
-
Prev();
|
|
204
|
-
|
|
205
|
-
return ret;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
inline TReference operator*() const noexcept {
|
|
209
|
-
return *Item_->Node();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
inline TPointer operator->() const noexcept {
|
|
213
|
-
return Item_->Node();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private:
|
|
217
|
-
TItem* Item_;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
template <class TIterator>
|
|
221
|
-
class TReverseIteratorBase {
|
|
222
|
-
public:
|
|
223
|
-
using TItem = typename TIterator::TItem;
|
|
224
|
-
using TReference = typename TIterator::TReference;
|
|
225
|
-
using TPointer = typename TIterator::TPointer;
|
|
226
|
-
|
|
227
|
-
using iterator_category = typename TIterator::iterator_category;
|
|
228
|
-
using difference_type = typename TIterator::difference_type;
|
|
229
|
-
|
|
230
|
-
using value_type = typename TIterator::value_type;
|
|
231
|
-
using reference = typename TIterator::reference;
|
|
232
|
-
using pointer = typename TIterator::pointer;
|
|
233
|
-
|
|
234
|
-
inline TReverseIteratorBase() noexcept = default;
|
|
235
|
-
|
|
236
|
-
template <class TIterator_>
|
|
237
|
-
inline TReverseIteratorBase(const TReverseIteratorBase<TIterator_>& right) noexcept
|
|
238
|
-
: Current_(right.Base())
|
|
239
|
-
{
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
inline explicit TReverseIteratorBase(TIterator item) noexcept
|
|
243
|
-
: Current_(item)
|
|
244
|
-
{
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
inline TIterator Base() const noexcept {
|
|
248
|
-
return Current_;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
inline TItem* Item() const noexcept {
|
|
252
|
-
TIterator ret = Current_;
|
|
253
|
-
|
|
254
|
-
return (--ret).Item();
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
inline void Next() noexcept {
|
|
258
|
-
Current_.Prev();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
inline void Prev() noexcept {
|
|
262
|
-
Current_.Next();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
template <class TIterator_>
|
|
266
|
-
inline bool operator==(const TReverseIteratorBase<TIterator_>& right) const noexcept {
|
|
267
|
-
return Base() == right.Base();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
template <class TIterator_>
|
|
271
|
-
inline bool operator!=(const TReverseIteratorBase<TIterator_>& right) const noexcept {
|
|
272
|
-
return Base() != right.Base();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
inline TReverseIteratorBase& operator++() noexcept {
|
|
276
|
-
Next();
|
|
277
|
-
|
|
278
|
-
return *this;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
inline TReverseIteratorBase operator++(int) noexcept {
|
|
282
|
-
TReverseIteratorBase ret(*this);
|
|
283
|
-
|
|
284
|
-
Next();
|
|
285
|
-
|
|
286
|
-
return ret;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
inline TReverseIteratorBase& operator--() noexcept {
|
|
290
|
-
Prev();
|
|
291
|
-
|
|
292
|
-
return *this;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
inline TReverseIteratorBase operator--(int) noexcept {
|
|
296
|
-
TReverseIteratorBase ret(*this);
|
|
297
|
-
|
|
298
|
-
Prev();
|
|
299
|
-
|
|
300
|
-
return ret;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
inline TReference operator*() const noexcept {
|
|
304
|
-
TIterator ret = Current_;
|
|
305
|
-
|
|
306
|
-
return *--ret;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
inline TPointer operator->() const noexcept {
|
|
310
|
-
TIterator ret = Current_;
|
|
311
|
-
|
|
312
|
-
return &*--ret;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
private:
|
|
316
|
-
TIterator Current_;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
public:
|
|
320
|
-
using TIterator = TIteratorBase<TListItem, T>;
|
|
321
|
-
using TConstIterator = TIteratorBase<const TListItem, const T>;
|
|
322
|
-
|
|
323
|
-
using TReverseIterator = TReverseIteratorBase<TIterator>;
|
|
324
|
-
using TConstReverseIterator = TReverseIteratorBase<TConstIterator>;
|
|
325
|
-
|
|
326
|
-
using iterator = TIterator;
|
|
327
|
-
using const_iterator = TConstIterator;
|
|
328
|
-
|
|
329
|
-
using reverse_iterator = TReverseIterator;
|
|
330
|
-
using const_reverse_iterator = TConstReverseIterator;
|
|
331
|
-
|
|
332
|
-
public:
|
|
333
|
-
inline void Swap(TIntrusiveList& right) noexcept {
|
|
334
|
-
TIntrusiveList temp;
|
|
335
|
-
|
|
336
|
-
temp.Append(right);
|
|
337
|
-
Y_ASSERT(right.Empty());
|
|
338
|
-
right.Append(*this);
|
|
339
|
-
Y_ASSERT(this->Empty());
|
|
340
|
-
this->Append(temp);
|
|
341
|
-
Y_ASSERT(temp.Empty());
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
public:
|
|
345
|
-
inline TIntrusiveList() noexcept = default;
|
|
346
|
-
|
|
347
|
-
inline ~TIntrusiveList() = default;
|
|
348
|
-
|
|
349
|
-
inline TIntrusiveList(TIntrusiveList&& right) noexcept {
|
|
350
|
-
this->Swap(right);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
inline TIntrusiveList& operator=(TIntrusiveList&& rhs) noexcept {
|
|
354
|
-
this->Swap(rhs);
|
|
355
|
-
return *this;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
inline explicit operator bool() const noexcept {
|
|
359
|
-
return !Empty();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
Y_PURE_FUNCTION
|
|
363
|
-
inline bool Empty() const noexcept {
|
|
364
|
-
return End_.Empty();
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
inline size_t Size() const noexcept {
|
|
368
|
-
return std::distance(Begin(), End());
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
inline void Remove(TListItem* item) noexcept {
|
|
372
|
-
item->Unlink();
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
inline void Clear() noexcept {
|
|
376
|
-
End_.Unlink();
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
public:
|
|
380
|
-
inline TIterator Begin() noexcept {
|
|
381
|
-
return ++End();
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
inline TIterator End() noexcept {
|
|
385
|
-
return TIterator(&End_);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
inline TConstIterator Begin() const noexcept {
|
|
389
|
-
return ++End();
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
inline TConstIterator End() const noexcept {
|
|
393
|
-
return TConstIterator(&End_);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
inline TReverseIterator RBegin() noexcept {
|
|
397
|
-
return TReverseIterator(End());
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
inline TReverseIterator REnd() noexcept {
|
|
401
|
-
return TReverseIterator(Begin());
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
inline TConstReverseIterator RBegin() const noexcept {
|
|
405
|
-
return TConstReverseIterator(End());
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
inline TConstReverseIterator REnd() const noexcept {
|
|
409
|
-
return TConstReverseIterator(Begin());
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
inline TConstIterator CBegin() const noexcept {
|
|
413
|
-
return Begin();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
inline TConstIterator CEnd() const noexcept {
|
|
417
|
-
return End();
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
inline TConstReverseIterator CRBegin() const noexcept {
|
|
421
|
-
return RBegin();
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
inline TConstReverseIterator CREnd() const noexcept {
|
|
425
|
-
return REnd();
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
public:
|
|
429
|
-
inline iterator begin() noexcept {
|
|
430
|
-
return Begin();
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
inline iterator end() noexcept {
|
|
434
|
-
return End();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
inline const_iterator begin() const noexcept {
|
|
438
|
-
return Begin();
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
inline const_iterator end() const noexcept {
|
|
442
|
-
return End();
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
inline reverse_iterator rbegin() noexcept {
|
|
446
|
-
return RBegin();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
inline reverse_iterator rend() noexcept {
|
|
450
|
-
return REnd();
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
inline const_iterator cbegin() const noexcept {
|
|
454
|
-
return CBegin();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
inline const_iterator cend() const noexcept {
|
|
458
|
-
return CEnd();
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
inline const_reverse_iterator crbegin() const noexcept {
|
|
462
|
-
return CRBegin();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
inline const_reverse_iterator crend() const noexcept {
|
|
466
|
-
return CREnd();
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
public:
|
|
470
|
-
inline T* Back() noexcept {
|
|
471
|
-
return End_.Prev()->Node();
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
inline T* Front() noexcept {
|
|
475
|
-
return End_.Next()->Node();
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
inline const T* Back() const noexcept {
|
|
479
|
-
return End_.Prev()->Node();
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
inline const T* Front() const noexcept {
|
|
483
|
-
return End_.Next()->Node();
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
inline void PushBack(TListItem* item) noexcept {
|
|
487
|
-
item->LinkBefore(End_);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
inline void PushFront(TListItem* item) noexcept {
|
|
491
|
-
item->LinkAfter(End_);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
inline T* PopBack() noexcept {
|
|
495
|
-
TListItem* const ret = End_.Prev();
|
|
496
|
-
|
|
497
|
-
ret->Unlink();
|
|
498
|
-
|
|
499
|
-
return ret->Node();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
inline T* PopFront() noexcept {
|
|
503
|
-
TListItem* const ret = End_.Next();
|
|
504
|
-
|
|
505
|
-
ret->Unlink();
|
|
506
|
-
|
|
507
|
-
return ret->Node();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
inline void Append(TIntrusiveList& list) noexcept {
|
|
511
|
-
Cut(list.Begin(), list.End(), End());
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
|
|
515
|
-
if (begin == end) {
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
TListItem* const cutFront = begin.Item();
|
|
520
|
-
TListItem* const gapBack = end.Item();
|
|
521
|
-
|
|
522
|
-
TListItem* const gapFront = cutFront->Prev();
|
|
523
|
-
TListItem* const cutBack = gapBack->Prev();
|
|
524
|
-
|
|
525
|
-
gapFront->SetNext(gapBack);
|
|
526
|
-
gapBack->SetPrev(gapFront);
|
|
527
|
-
|
|
528
|
-
TListItem* const pasteBack = pasteBefore.Item();
|
|
529
|
-
TListItem* const pasteFront = pasteBack->Prev();
|
|
530
|
-
|
|
531
|
-
pasteFront->SetNext(cutFront);
|
|
532
|
-
cutFront->SetPrev(pasteFront);
|
|
533
|
-
|
|
534
|
-
cutBack->SetNext(pasteBack);
|
|
535
|
-
pasteBack->SetPrev(cutBack);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
public:
|
|
539
|
-
template <class TFunctor>
|
|
540
|
-
inline void ForEach(TFunctor&& functor) {
|
|
541
|
-
TIterator i = Begin();
|
|
542
|
-
|
|
543
|
-
while (i != End()) {
|
|
544
|
-
functor(&*(i++));
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
template <class TFunctor>
|
|
549
|
-
inline void ForEach(TFunctor&& functor) const {
|
|
550
|
-
TConstIterator i = Begin();
|
|
551
|
-
|
|
552
|
-
while (i != End()) {
|
|
553
|
-
functor(&*(i++));
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
template <class TComparer>
|
|
558
|
-
inline void QuickSort(TComparer&& comparer) {
|
|
559
|
-
if (Begin() == End() || ++Begin() == End()) {
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
T* const pivot = PopFront();
|
|
564
|
-
TIntrusiveList bigger;
|
|
565
|
-
TIterator i = Begin();
|
|
566
|
-
|
|
567
|
-
while (i != End()) {
|
|
568
|
-
if (comparer(*pivot, *i)) {
|
|
569
|
-
bigger.PushBack(&*i++);
|
|
570
|
-
} else {
|
|
571
|
-
++i;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
this->QuickSort(comparer);
|
|
576
|
-
bigger.QuickSort(comparer);
|
|
577
|
-
|
|
578
|
-
PushBack(pivot);
|
|
579
|
-
Append(bigger);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
private:
|
|
583
|
-
inline TIntrusiveList(const TIntrusiveList&) = delete;
|
|
584
|
-
inline TIntrusiveList& operator=(const TIntrusiveList&) = delete;
|
|
585
|
-
|
|
586
|
-
private:
|
|
587
|
-
TListItem End_;
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
template <class T, class D, class Tag>
|
|
591
|
-
class TIntrusiveListWithAutoDelete: public TIntrusiveList<T, Tag> {
|
|
592
|
-
public:
|
|
593
|
-
using TIterator = typename TIntrusiveList<T, Tag>::TIterator;
|
|
594
|
-
using TConstIterator = typename TIntrusiveList<T, Tag>::TConstIterator;
|
|
595
|
-
|
|
596
|
-
using TReverseIterator = typename TIntrusiveList<T, Tag>::TReverseIterator;
|
|
597
|
-
using TConstReverseIterator = typename TIntrusiveList<T, Tag>::TConstReverseIterator;
|
|
598
|
-
|
|
599
|
-
using iterator = TIterator;
|
|
600
|
-
using const_iterator = TConstIterator;
|
|
601
|
-
|
|
602
|
-
using reverse_iterator = TReverseIterator;
|
|
603
|
-
using const_reverse_iterator = TConstReverseIterator;
|
|
604
|
-
|
|
605
|
-
public:
|
|
606
|
-
inline TIntrusiveListWithAutoDelete() noexcept = default;
|
|
607
|
-
|
|
608
|
-
inline TIntrusiveListWithAutoDelete(TIntrusiveListWithAutoDelete&& right) noexcept
|
|
609
|
-
: TIntrusiveList<T, Tag>(std::move(right))
|
|
610
|
-
{
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
inline ~TIntrusiveListWithAutoDelete() {
|
|
614
|
-
this->Clear();
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
TIntrusiveListWithAutoDelete& operator=(TIntrusiveListWithAutoDelete&& rhs) noexcept {
|
|
618
|
-
TIntrusiveList<T, Tag>::operator=(std::move(rhs));
|
|
619
|
-
return *this;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
public:
|
|
623
|
-
inline void Clear() noexcept {
|
|
624
|
-
this->ForEach([](auto* item) {
|
|
625
|
-
D::Destroy(item);
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
inline static void Cut(TIterator begin, TIterator end) noexcept {
|
|
630
|
-
TIntrusiveListWithAutoDelete<T, D, Tag> temp;
|
|
631
|
-
Cut(begin, end, temp.End());
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
inline static void Cut(TIterator begin, TIterator end, TIterator pasteBefore) noexcept {
|
|
635
|
-
TIntrusiveList<T, Tag>::Cut(begin, end, pasteBefore);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
/*
|
|
640
|
-
* one-way linked list
|
|
641
|
-
*/
|
|
642
|
-
template <class T, class Tag = TIntrusiveListDefaultTag>
|
|
643
|
-
class TIntrusiveSListItem {
|
|
644
|
-
private:
|
|
645
|
-
using TListItem = TIntrusiveSListItem<T, Tag>;
|
|
646
|
-
|
|
647
|
-
public:
|
|
648
|
-
inline TIntrusiveSListItem() noexcept
|
|
649
|
-
: Next_(nullptr)
|
|
650
|
-
{
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
inline ~TIntrusiveSListItem() = default;
|
|
654
|
-
|
|
655
|
-
inline bool IsEnd() const noexcept {
|
|
656
|
-
return Next_ == nullptr;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
inline TListItem* Next() noexcept {
|
|
660
|
-
return Next_;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
inline const TListItem* Next() const noexcept {
|
|
664
|
-
return Next_;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
inline void SetNext(TListItem* item) noexcept {
|
|
668
|
-
Next_ = item;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
public:
|
|
672
|
-
inline T* Node() noexcept {
|
|
673
|
-
return static_cast<T*>(this);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
inline const T* Node() const noexcept {
|
|
677
|
-
return static_cast<const T*>(this);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
private:
|
|
681
|
-
TListItem* Next_;
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
template <class T, class Tag>
|
|
685
|
-
class TIntrusiveSList {
|
|
686
|
-
private:
|
|
687
|
-
using TListItem = TIntrusiveSListItem<T, Tag>;
|
|
688
|
-
|
|
689
|
-
public:
|
|
690
|
-
template <class TListItem, class TNode>
|
|
691
|
-
class TIteratorBase {
|
|
692
|
-
public:
|
|
693
|
-
using TItem = TListItem;
|
|
694
|
-
using TReference = TNode&;
|
|
695
|
-
using TPointer = TNode*;
|
|
696
|
-
|
|
697
|
-
using difference_type = std::ptrdiff_t;
|
|
698
|
-
using value_type = TNode;
|
|
699
|
-
using pointer = TPointer;
|
|
700
|
-
using reference = TReference;
|
|
701
|
-
using iterator_category = std::forward_iterator_tag;
|
|
702
|
-
|
|
703
|
-
inline TIteratorBase(TListItem* item) noexcept
|
|
704
|
-
: Item_(item)
|
|
705
|
-
{
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
inline void Next() noexcept {
|
|
709
|
-
Item_ = Item_->Next();
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
inline bool operator==(const TIteratorBase& right) const noexcept {
|
|
713
|
-
return Item_ == right.Item_;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
inline bool operator!=(const TIteratorBase& right) const noexcept {
|
|
717
|
-
return Item_ != right.Item_;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
inline TIteratorBase& operator++() noexcept {
|
|
721
|
-
Next();
|
|
722
|
-
|
|
723
|
-
return *this;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
inline TIteratorBase operator++(int) noexcept {
|
|
727
|
-
TIteratorBase ret(*this);
|
|
728
|
-
|
|
729
|
-
Next();
|
|
730
|
-
|
|
731
|
-
return ret;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
inline TNode& operator*() noexcept {
|
|
735
|
-
return *Item_->Node();
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
inline TNode* operator->() noexcept {
|
|
739
|
-
return Item_->Node();
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
private:
|
|
743
|
-
TListItem* Item_;
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
public:
|
|
747
|
-
using TIterator = TIteratorBase<TListItem, T>;
|
|
748
|
-
using TConstIterator = TIteratorBase<const TListItem, const T>;
|
|
749
|
-
|
|
750
|
-
using iterator = TIterator;
|
|
751
|
-
using const_iterator = TConstIterator;
|
|
752
|
-
|
|
753
|
-
public:
|
|
754
|
-
inline TIntrusiveSList() noexcept
|
|
755
|
-
: Begin_(nullptr)
|
|
756
|
-
{
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
inline void Swap(TIntrusiveSList& right) noexcept {
|
|
760
|
-
DoSwap(Begin_, right.Begin_);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
inline explicit operator bool() const noexcept {
|
|
764
|
-
return !Empty();
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
Y_PURE_FUNCTION
|
|
768
|
-
inline bool Empty() const noexcept {
|
|
769
|
-
return Begin_ == nullptr;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
inline size_t Size() const noexcept {
|
|
773
|
-
return std::distance(Begin(), End());
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
inline void Clear() noexcept {
|
|
777
|
-
Begin_ = nullptr;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
inline TIterator Begin() noexcept {
|
|
781
|
-
return TIterator(Begin_);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
inline TIterator End() noexcept {
|
|
785
|
-
return TIterator(nullptr);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
inline TConstIterator Begin() const noexcept {
|
|
789
|
-
return TConstIterator(Begin_);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
inline TConstIterator End() const noexcept {
|
|
793
|
-
return TConstIterator(nullptr);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
inline TConstIterator CBegin() const noexcept {
|
|
797
|
-
return Begin();
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
inline TConstIterator CEnd() const noexcept {
|
|
801
|
-
return End();
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
//compat methods
|
|
805
|
-
inline iterator begin() noexcept {
|
|
806
|
-
return Begin();
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
inline iterator end() noexcept {
|
|
810
|
-
return End();
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
inline const_iterator begin() const noexcept {
|
|
814
|
-
return Begin();
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
inline const_iterator end() const noexcept {
|
|
818
|
-
return End();
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
inline const_iterator cbegin() const noexcept {
|
|
822
|
-
return CBegin();
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
inline const_iterator cend() const noexcept {
|
|
826
|
-
return CEnd();
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
inline T* Front() noexcept {
|
|
830
|
-
Y_ASSERT(Begin_);
|
|
831
|
-
return Begin_->Node();
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
inline const T* Front() const noexcept {
|
|
835
|
-
Y_ASSERT(Begin_);
|
|
836
|
-
return Begin_->Node();
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
inline void PushFront(TListItem* item) noexcept {
|
|
840
|
-
item->SetNext(Begin_);
|
|
841
|
-
Begin_ = item;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
inline T* PopFront() noexcept {
|
|
845
|
-
Y_ASSERT(Begin_);
|
|
846
|
-
|
|
847
|
-
TListItem* const ret = Begin_;
|
|
848
|
-
Begin_ = Begin_->Next();
|
|
849
|
-
|
|
850
|
-
return ret->Node();
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
inline void Reverse() noexcept {
|
|
854
|
-
TIntrusiveSList temp;
|
|
855
|
-
|
|
856
|
-
while (!Empty()) {
|
|
857
|
-
temp.PushFront(PopFront());
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
this->Swap(temp);
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
template <class TFunctor>
|
|
864
|
-
inline void ForEach(TFunctor&& functor) const noexcept(noexcept(functor(std::declval<TListItem>().Node()))) {
|
|
865
|
-
TListItem* i = Begin_;
|
|
866
|
-
|
|
867
|
-
while (i) {
|
|
868
|
-
TListItem* const next = i->Next();
|
|
869
|
-
functor(i->Node());
|
|
870
|
-
i = next;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
private:
|
|
875
|
-
TListItem* Begin_;
|
|
876
|
-
};
|