diff options
author | denplusplus <denplusplus@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:34 +0300 |
commit | 57c20d143e8a438cd76b9fdc3ca2e8ee3ac1f32a (patch) | |
tree | cc63639f8e502db19a82c20e2861c6d1edbf9fea /library/cpp/containers | |
parent | 464ba3814a83db4f2d5327393b0b6eaf0c86bfd7 (diff) | |
download | ydb-57c20d143e8a438cd76b9fdc3ca2e8ee3ac1f32a.tar.gz |
Restoring authorship annotation for <denplusplus@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers')
-rw-r--r-- | library/cpp/containers/comptrie/chunked_helpers_trie.h | 352 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_impl.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_trie.h | 10 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_ut.cpp | 112 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/make_fast_layout.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/minimize.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/node.h | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/write_trie_backwards.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/writeable_node.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/ya.make | 6 | ||||
-rw-r--r-- | library/cpp/containers/intrusive_rb_tree/rb_tree.h | 38 |
11 files changed, 265 insertions, 265 deletions
diff --git a/library/cpp/containers/comptrie/chunked_helpers_trie.h b/library/cpp/containers/comptrie/chunked_helpers_trie.h index cfa35f5ba2..4095ca8b19 100644 --- a/library/cpp/containers/comptrie/chunked_helpers_trie.h +++ b/library/cpp/containers/comptrie/chunked_helpers_trie.h @@ -1,218 +1,218 @@ -#pragma once - +#pragma once + #include <library/cpp/on_disk/chunks/chunked_helpers.h> - -#include "comptrie.h" - -class TTrieSet { -private: - TCompactTrie<char> Trie; - -public: - TTrieSet(const TBlob& blob) - : Trie(blob) - { - } - - bool Has(const char* key) const { - return Trie.Find(key, strlen(key)); - } - - bool FindLongestPrefix(const char* key, size_t keylen, size_t* prefixLen) { - return Trie.FindLongestPrefix(key, keylen, prefixLen); - } -}; - + +#include "comptrie.h" + +class TTrieSet { +private: + TCompactTrie<char> Trie; + +public: + TTrieSet(const TBlob& blob) + : Trie(blob) + { + } + + bool Has(const char* key) const { + return Trie.Find(key, strlen(key)); + } + + bool FindLongestPrefix(const char* key, size_t keylen, size_t* prefixLen) { + return Trie.FindLongestPrefix(key, keylen, prefixLen); + } +}; + template <bool sorted = false> -class TTrieSetWriter { -private: - TCompactTrieBuilder<char> Builder; - -public: - TTrieSetWriter(bool isSorted = sorted) +class TTrieSetWriter { +private: + TCompactTrieBuilder<char> Builder; + +public: + TTrieSetWriter(bool isSorted = sorted) : Builder(isSorted ? CTBF_PREFIX_GROUPED : CTBF_NONE) - { - } - - void Add(const char* key, size_t keylen) { - Builder.Add(key, keylen, 0); + { + } + + void Add(const char* key, size_t keylen) { + Builder.Add(key, keylen, 0); assert(Has(((TString)key).substr(0, keylen).data())); - } - - void Add(const char* key) { - Add(key, strlen(key)); - } - - bool Has(const char* key) const { - ui64 dummy; - return Builder.Find(key, strlen(key), &dummy); - } - + } + + void Add(const char* key) { + Add(key, strlen(key)); + } + + bool Has(const char* key) const { + ui64 dummy; + return Builder.Find(key, strlen(key), &dummy); + } + void Save(IOutputStream& out) const { - Builder.Save(out); - } - - void Clear() { - Builder.Clear(); - } -}; - + Builder.Save(out); + } + + void Clear() { + Builder.Clear(); + } +}; + template <bool isWriter, bool sorted = false> -struct TTrieSetG; - +struct TTrieSetG; + template <bool sorted> -struct TTrieSetG<false, sorted> { - typedef TTrieSet T; -}; - +struct TTrieSetG<false, sorted> { + typedef TTrieSet T; +}; + template <bool sorted> -struct TTrieSetG<true, sorted> { - typedef TTrieSetWriter<sorted> T; -}; - +struct TTrieSetG<true, sorted> { + typedef TTrieSetWriter<sorted> T; +}; + template <typename T> -class TTrieMap { -private: - TCompactTrie<char> Trie; +class TTrieMap { +private: + TCompactTrie<char> Trie; static_assert(sizeof(T) <= sizeof(ui64), "expect sizeof(T) <= sizeof(ui64)"); - -public: - TTrieMap(const TBlob& blob) - : Trie(blob) - { - } - - bool Get(const char* key, T* value) const { - ui64 trieValue; - if (Trie.Find(key, strlen(key), &trieValue)) { + +public: + TTrieMap(const TBlob& blob) + : Trie(blob) + { + } + + bool Get(const char* key, T* value) const { + ui64 trieValue; + if (Trie.Find(key, strlen(key), &trieValue)) { *value = ReadUnaligned<T>(&trieValue); - return true; - } else { - return false; - } - } - - T Get(const char* key, T def = T()) const { - ui64 trieValue; - if (Trie.Find(key, strlen(key), &trieValue)) { + return true; + } else { + return false; + } + } + + T Get(const char* key, T def = T()) const { + ui64 trieValue; + if (Trie.Find(key, strlen(key), &trieValue)) { return ReadUnaligned<T>(&trieValue); - } else { - return def; - } - } + } else { + return def; + } + } const TCompactTrie<char>& GetTrie() const { return Trie; } -}; - +}; + template <typename T, bool sorted = false> -class TTrieMapWriter { -private: - typedef TCompactTrieBuilder<char> TBuilder; - TBuilder Builder; +class TTrieMapWriter { +private: + typedef TCompactTrieBuilder<char> TBuilder; + TBuilder Builder; static_assert(sizeof(T) <= sizeof(ui64), "expect sizeof(T) <= sizeof(ui64)"); -#ifndef NDEBUG - bool IsSorted; -#endif - -public: - TTrieMapWriter(bool isSorted = sorted) +#ifndef NDEBUG + bool IsSorted; +#endif + +public: + TTrieMapWriter(bool isSorted = sorted) : Builder(isSorted ? CTBF_PREFIX_GROUPED : CTBF_NONE) -#ifndef NDEBUG - , IsSorted(isSorted) -#endif - { - } - - void Add(const char* key, const T& value) { +#ifndef NDEBUG + , IsSorted(isSorted) +#endif + { + } + + void Add(const char* key, const T& value) { ui64 intValue = 0; memcpy(&intValue, &value, sizeof(T)); Builder.Add(key, strlen(key), intValue); -#ifndef NDEBUG +#ifndef NDEBUG /* - if (!IsSorted) { - T test; - assert(Get(key, &test) && value == test); - } + if (!IsSorted) { + T test; + assert(Get(key, &test) && value == test); + } */ -#endif - } - +#endif + } + void Add(const TString& s, const T& value) { ui64 intValue = 0; memcpy(&intValue, &value, sizeof(T)); Builder.Add(s.data(), s.size(), intValue); - } - - bool Get(const char* key, T* value) const { - ui64 trieValue; - if (Builder.Find(key, strlen(key), &trieValue)) { + } + + bool Get(const char* key, T* value) const { + ui64 trieValue; + if (Builder.Find(key, strlen(key), &trieValue)) { *value = ReadUnaligned<T>(&trieValue); - return true; - } else { - return false; - } - } - - T Get(const char* key, T def = (T)0) const { - ui64 trieValue; - if (Builder.Find(key, strlen(key), &trieValue)) { + return true; + } else { + return false; + } + } + + T Get(const char* key, T def = (T)0) const { + ui64 trieValue; + if (Builder.Find(key, strlen(key), &trieValue)) { return ReadUnaligned<T>(&trieValue); - } else { - return def; - } - } - + } else { + return def; + } + } + void Save(IOutputStream& out, bool minimize = false) const { - if (minimize) { + if (minimize) { CompactTrieMinimize<TBuilder>(out, Builder, false); - } else { - Builder.Save(out); - } - } - - void Clear() { - Builder.Clear(); - } -}; - + } else { + Builder.Save(out); + } + } + + void Clear() { + Builder.Clear(); + } +}; + template <typename T> -class TTrieSortedMapWriter { -private: +class TTrieSortedMapWriter { +private: typedef std::pair<TString, T> TValue; typedef TVector<TValue> TValues; - TValues Values; - -public: + TValues Values; + +public: TTrieSortedMapWriter() = default; - - void Add(const char* key, const T& value) { - Values.push_back(TValue(key, value)); - } - + + void Add(const char* key, const T& value) { + Values.push_back(TValue(key, value)); + } + void Save(IOutputStream& out) { Sort(Values.begin(), Values.end()); - TTrieMapWriter<T, true> writer; - for (typename TValues::const_iterator toValue = Values.begin(); toValue != Values.end(); ++toValue) + TTrieMapWriter<T, true> writer; + for (typename TValues::const_iterator toValue = Values.begin(); toValue != Values.end(); ++toValue) writer.Add(toValue->first.data(), toValue->second); - writer.Save(out); - } - - void Clear() { - Values.clear(); - } -}; - + writer.Save(out); + } + + void Clear() { + Values.clear(); + } +}; + template <typename X, bool isWriter, bool sorted = false> -struct TTrieMapG; - +struct TTrieMapG; + template <typename X, bool sorted> -struct TTrieMapG<X, false, sorted> { - typedef TTrieMap<X> T; -}; - +struct TTrieMapG<X, false, sorted> { + typedef TTrieMap<X> T; +}; + template <typename X, bool sorted> -struct TTrieMapG<X, true, sorted> { - typedef TTrieMapWriter<X, sorted> T; -}; +struct TTrieMapG<X, true, sorted> { + typedef TTrieMapWriter<X, sorted> T; +}; diff --git a/library/cpp/containers/comptrie/comptrie_impl.cpp b/library/cpp/containers/comptrie/comptrie_impl.cpp index a116ab6d1e..d16fc076f6 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.cpp +++ b/library/cpp/containers/comptrie/comptrie_impl.cpp @@ -1,5 +1,5 @@ #include "comptrie_impl.h" - + #include <util/system/rusage.h> #include <util/stream/output.h> diff --git a/library/cpp/containers/comptrie/comptrie_trie.h b/library/cpp/containers/comptrie/comptrie_trie.h index 40ec1e52b3..633a299e8e 100644 --- a/library/cpp/containers/comptrie/comptrie_trie.h +++ b/library/cpp/containers/comptrie/comptrie_trie.h @@ -95,12 +95,12 @@ public: return Get(key.data(), key.size()); } TData GetDefault(const TKeyBuf& key, const TData& def) const { - TData value; + TData value; if (!Find(key.data(), key.size(), &value)) - return def; - else - return value; - } + return def; + else + return value; + } const TBlob& Data() const { return DataHolder; diff --git a/library/cpp/containers/comptrie/comptrie_ut.cpp b/library/cpp/containers/comptrie/comptrie_ut.cpp index 74bee09b5d..39a0ccb068 100644 --- a/library/cpp/containers/comptrie/comptrie_ut.cpp +++ b/library/cpp/containers/comptrie/comptrie_ut.cpp @@ -11,7 +11,7 @@ #include <util/generic/vector.h> #include <util/generic/ptr.h> #include <util/generic/ylimits.h> - + #include <util/folder/dirut.h> #include <util/random/random.h> @@ -31,8 +31,8 @@ class TCompactTrieTest: public TTestBase { -private: - UNIT_TEST_SUITE(TCompactTrieTest); +private: + UNIT_TEST_SUITE(TCompactTrieTest); UNIT_TEST(TestTrie8); UNIT_TEST(TestTrie16); UNIT_TEST(TestTrie32); @@ -113,16 +113,16 @@ private: UNIT_TEST(TestPatternSearcherSimple); UNIT_TEST(TestPatternSearcherRandom); - UNIT_TEST_SUITE_END(); - - static const char* SampleData[]; + UNIT_TEST_SUITE_END(); + + static const char* SampleData[]; template <class T> void CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout); template <class T> - void CheckData(const char* src, size_t len); - + void CheckData(const char* src, size_t len); + template <class T> void CheckUpperBound(const char* src, size_t len); @@ -195,10 +195,10 @@ public: void TestMinimizedTrieIterator32(); void TestPhraseSearch(); - void TestAddGet(); - void TestEmpty(); + void TestAddGet(); + void TestEmpty(); void TestUninitializedNonEmpty(); - void TestRandom(); + void TestRandom(); void TestFindTails(); void TestPrefixGrouped(); void CrashTestPrefixGrouped(); @@ -261,10 +261,10 @@ public: TFastRng<ui64>& rng ); void TestPatternSearcherRandom(); -}; - -UNIT_TEST_SUITE_REGISTRATION(TCompactTrieTest); - +}; + +UNIT_TEST_SUITE_REGISTRATION(TCompactTrieTest); + const char* TCompactTrieTest::SampleData[] = { "", "a", "b", "c", "d", @@ -275,7 +275,7 @@ const char* TCompactTrieTest::SampleData[] = { "fbbaa", "c\x85\xA4\xBF" // Just something outside ASCII. }; - + template <class T> typename TCompactTrie<T>::TKey MakeWideKey(const char* str, size_t len) { typename TCompactTrie<T>::TKey buffer; @@ -299,12 +299,12 @@ typename TCompactTrie<T>::TKey MakeWideKey(const TStringBuf& buf) { template <class T> void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFastLayout) { TCompactTrieBuilder<T> builder; - + for (auto& i : SampleData) { size_t len = strlen(i); builder.Add(MakeWideKey<T>(i, len), len * 2); - } + } TBufferOutput tmp2; IOutputStream& currentOutput = useFastLayout ? tmp2 : out; @@ -318,8 +318,8 @@ void TCompactTrieTest::CreateTrie(IOutputStream& out, bool minimize, bool useFas if (useFastLayout) { CompactTrieMakeFastLayout<TCompactTriePacker<T>>(out, tmp2.Buffer().Data(), tmp2.Buffer().Size(), false); } -} - +} + // Iterates over all strings of length <= 4 made of letters a-g. static bool LexicographicStep(TString& s) { if (s.length() < 4) { @@ -360,14 +360,14 @@ void TCompactTrieTest::CheckUpperBound(const char* data, size_t datalen) { template <class T> void TCompactTrieTest::CheckData(const char* data, size_t datalen) { TCompactTrie<T> trie(data, datalen); - + UNIT_ASSERT_VALUES_EQUAL(Y_ARRAY_SIZE(SampleData), trie.Size()); for (auto& i : SampleData) { size_t len = strlen(i); ui64 value = 0; size_t prefixLen = 0; - + typename TCompactTrie<T>::TKey key = MakeWideKey<T>(i, len); UNIT_ASSERT(trie.Find(key, &value)); UNIT_ASSERT_EQUAL(len * 2, value); @@ -385,9 +385,9 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT(trie.FindLongestPrefix(key, &prefixLen, &value)); UNIT_ASSERT_EQUAL(1, prefixLen); UNIT_ASSERT_EQUAL(2, value); - + badkey = i; - badkey += "x"; + badkey += "x"; key = MakeWideKey<T>(badkey); UNIT_ASSERT(!trie.Find(key)); value = 1234; @@ -398,7 +398,7 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { UNIT_ASSERT_EQUAL(len * 2, value); UNIT_ASSERT(trie.FindLongestPrefix(key, &prefixLen, nullptr)); UNIT_ASSERT_EQUAL(len, prefixLen); - } + } TString testkey("fbbaa"); typename TCompactTrie<T>::TKey key = MakeWideKey<T>(testkey); @@ -417,8 +417,8 @@ void TCompactTrieTest::CheckData(const char* data, size_t datalen) { value = 12345678; UNIT_ASSERT(!trie.Find(key, &value)); UNIT_ASSERT_EQUAL(12345678, value); //Failed Find() should not change value -} - +} + template <class T> void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { typedef typename TCompactTrie<T>::TKey TKey; @@ -487,19 +487,19 @@ void TCompactTrieTest::CheckIterator(const char* data, size_t datalen) { template <class T> void TCompactTrieTest::TestTrie(bool minimize, bool useFastLayout) { - TBufferOutput bufout; + TBufferOutput bufout; CreateTrie<T>(bufout, minimize, useFastLayout); CheckData<T>(bufout.Buffer().Data(), bufout.Buffer().Size()); CheckUpperBound<T>(bufout.Buffer().Data(), bufout.Buffer().Size()); -} - +} + template <class T> void TCompactTrieTest::TestTrieIterator(bool minimize) { - TBufferOutput bufout; + TBufferOutput bufout; CreateTrie<T>(bufout, minimize, false); CheckIterator<T>(bufout.Buffer().Data(), bufout.Buffer().Size()); -} - +} + void TCompactTrieTest::TestTrie8() { TestTrie<char>(false, false); } @@ -586,30 +586,30 @@ void TCompactTrieTest::TestPhraseSearch() { UNIT_ASSERT(matches.size() == 0); } -void TCompactTrieTest::TestAddGet() { +void TCompactTrieTest::TestAddGet() { TCompactTrieBuilder<char> builder; builder.Add("abcd", 4, 1); builder.Add("acde", 4, 2); - ui64 dummy; + ui64 dummy; UNIT_ASSERT(builder.Find("abcd", 4, &dummy)); - UNIT_ASSERT(1 == dummy); + UNIT_ASSERT(1 == dummy); UNIT_ASSERT(builder.Find("acde", 4, &dummy)); - UNIT_ASSERT(2 == dummy); + UNIT_ASSERT(2 == dummy); UNIT_ASSERT(!builder.Find("fgdgfacde", 9, &dummy)); UNIT_ASSERT(!builder.Find("ab", 2, &dummy)); -} - -void TCompactTrieTest::TestEmpty() { +} + +void TCompactTrieTest::TestEmpty() { TCompactTrieBuilder<char> builder; ui64 dummy = 12345; size_t prefixLen; UNIT_ASSERT(!builder.Find("abc", 3, &dummy)); - TBufferOutput bufout; - builder.Save(bufout); - + TBufferOutput bufout; + builder.Save(bufout); + TCompactTrie<char> trie(bufout.Buffer().Data(), bufout.Buffer().Size()); UNIT_ASSERT(!trie.Find("abc", 3, &dummy)); - UNIT_ASSERT(!trie.Find("", 0, &dummy)); + UNIT_ASSERT(!trie.Find("", 0, &dummy)); UNIT_ASSERT(!trie.FindLongestPrefix("abc", 3, &prefixLen, &dummy)); UNIT_ASSERT(!trie.FindLongestPrefix("", 0, &prefixLen, &dummy)); UNIT_ASSERT_EQUAL(12345, dummy); @@ -624,8 +624,8 @@ void TCompactTrieTest::TestEmpty() { trieNull.FindPhrases(" ", 1, matches); // just to be sure it doesn't crash UNIT_ASSERT(trieNull.Begin() == trieNull.End()); -} - +} + void TCompactTrieTest::TestUninitializedNonEmpty() { TBufferOutput bufout; CreateTrie<char>(bufout, false, false); @@ -653,11 +653,11 @@ static char RandChar() { static TString RandStr(const size_t max) { size_t len = RandomNumber<size_t>() % max; TString key; - for (size_t j = 0; j < len; ++j) + for (size_t j = 0; j < len; ++j) key += RandChar(); - return key; -} - + return key; +} + template <class T, bool minimize> void TCompactTrieTest::TestRandom(const size_t n, const size_t maxKeySize) { const TStringBuf EMPTY_KEY = TStringBuf("", 1); @@ -676,16 +676,16 @@ void TCompactTrieTest::TestRandom(const size_t n, const size_t maxKeySize) { UNIT_ASSERT_C(builder.Find(key.data(), key.size(), &dummy), "key = " << HexEncode(TString(key))); UNIT_ASSERT(dummy == val); } - } + } - TBufferStream stream; - size_t len = builder.Save(stream); + TBufferStream stream; + size_t len = builder.Save(stream); TCompactTrie<char, typename T::TData, T> trie(stream.Buffer().Data(), len); - + TBufferStream buftmp; if (minimize) { CompactTrieMinimize<T>(buftmp, stream.Buffer().Data(), len, false); - } + } TCompactTrie<char, typename T::TData, T> trieMin(buftmp.Buffer().Data(), buftmp.Buffer().Size()); TCompactTrieBuilder<char, typename T::TData, T> prefixGroupedBuilder(CTBF_PREFIX_GROUPED); @@ -718,7 +718,7 @@ void TCompactTrieTest::TestRandom(const size_t n, const size_t maxKeySize) { UNIT_ASSERT_VALUES_EQUAL(stream.Buffer().Size(), prefixGroupedBuffer.Buffer().Size()); UNIT_ASSERT(0 == memcmp(stream.Buffer().Data(), prefixGroupedBuffer.Buffer().Data(), stream.Buffer().Size())); -} +} void TCompactTrieTest::TestRandom() { TestRandom<TIntPacker<ui64>, true>(1000, 1000); diff --git a/library/cpp/containers/comptrie/make_fast_layout.cpp b/library/cpp/containers/comptrie/make_fast_layout.cpp index ade78d7899..ac34ea2c66 100644 --- a/library/cpp/containers/comptrie/make_fast_layout.cpp +++ b/library/cpp/containers/comptrie/make_fast_layout.cpp @@ -3,7 +3,7 @@ #include "writeable_node.h" #include "write_trie_backwards.h" #include "comptrie_impl.h" - + #include <util/generic/hash.h> #include <util/generic/utility.h> diff --git a/library/cpp/containers/comptrie/minimize.cpp b/library/cpp/containers/comptrie/minimize.cpp index 80d0b25217..c802b176b4 100644 --- a/library/cpp/containers/comptrie/minimize.cpp +++ b/library/cpp/containers/comptrie/minimize.cpp @@ -3,7 +3,7 @@ #include "writeable_node.h" #include "write_trie_backwards.h" #include "comptrie_impl.h" - + #include <util/generic/hash.h> #include <util/generic/algorithm.h> diff --git a/library/cpp/containers/comptrie/node.h b/library/cpp/containers/comptrie/node.h index d6f4317db0..f84132ebde 100644 --- a/library/cpp/containers/comptrie/node.h +++ b/library/cpp/containers/comptrie/node.h @@ -1,5 +1,5 @@ #pragma once - + #include <cstddef> namespace NCompactTrie { diff --git a/library/cpp/containers/comptrie/write_trie_backwards.cpp b/library/cpp/containers/comptrie/write_trie_backwards.cpp index fd8c28b0ed..7019d0644b 100644 --- a/library/cpp/containers/comptrie/write_trie_backwards.cpp +++ b/library/cpp/containers/comptrie/write_trie_backwards.cpp @@ -5,7 +5,7 @@ #include <util/generic/buffer.h> #include <util/generic/vector.h> - + namespace NCompactTrie { size_t WriteTrieBackwards(IOutputStream& os, TReverseNodeEnumerator& enumerator, bool verbose) { if (verbose) { diff --git a/library/cpp/containers/comptrie/writeable_node.cpp b/library/cpp/containers/comptrie/writeable_node.cpp index 404003dbbd..eb4a9455d4 100644 --- a/library/cpp/containers/comptrie/writeable_node.cpp +++ b/library/cpp/containers/comptrie/writeable_node.cpp @@ -1,7 +1,7 @@ #include "writeable_node.h" #include "node.h" #include "comptrie_impl.h" - + namespace NCompactTrie { TWriteableNode::TWriteableNode() : LeafPos(nullptr) diff --git a/library/cpp/containers/comptrie/ya.make b/library/cpp/containers/comptrie/ya.make index 81352da4b2..7e859df864 100644 --- a/library/cpp/containers/comptrie/ya.make +++ b/library/cpp/containers/comptrie/ya.make @@ -25,11 +25,11 @@ SRCS( writeable_node.cpp ) -PEERDIR( +PEERDIR( library/cpp/packers library/cpp/containers/compact_vector library/cpp/on_disk/chunks util/draft -) - +) + END() diff --git a/library/cpp/containers/intrusive_rb_tree/rb_tree.h b/library/cpp/containers/intrusive_rb_tree/rb_tree.h index 0259452a14..0a833ae223 100644 --- a/library/cpp/containers/intrusive_rb_tree/rb_tree.h +++ b/library/cpp/containers/intrusive_rb_tree/rb_tree.h @@ -16,7 +16,7 @@ struct TRbTreeNodeBase { TBasePtr Parent_; TBasePtr Left_; TBasePtr Right_; - size_t Children_; + size_t Children_; inline TRbTreeNodeBase() noexcept { ReInitNode(); @@ -27,7 +27,7 @@ struct TRbTreeNodeBase { Parent_ = nullptr; Left_ = nullptr; Right_ = nullptr; - Children_ = 1; + Children_ = 1; } static TBasePtr MinimumNode(TBasePtr x) { @@ -43,19 +43,19 @@ struct TRbTreeNodeBase { return x; } - - static TBasePtr ByIndex(TBasePtr x, size_t index) { + + static TBasePtr ByIndex(TBasePtr x, size_t index) { if (x->Left_ != nullptr) { - if (index < x->Left_->Children_) - return ByIndex(x->Left_, index); - index -= x->Left_->Children_; - } - if (0 == index) - return x; - if (!x->Right_) - ythrow yexception() << "index not found"; - return ByIndex(x->Right_, index - 1); - } + if (index < x->Left_->Children_) + return ByIndex(x->Left_, index); + index -= x->Left_->Children_; + } + if (0 == index) + return x; + if (!x->Right_) + ythrow yexception() << "index not found"; + return ByIndex(x->Right_, index - 1); + } }; struct TRbTreeBaseIterator; @@ -397,7 +397,7 @@ public: return y; } - + template <class T1> inline size_t LessCount(const T1& k) const { auto x = LowerBound(k); @@ -544,8 +544,8 @@ void TRbGlobal<TDummy>::RotateLeft(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) { x->Parent_->Right_ = y; y->Left_ = x; x->Parent_ = y; - y->Children_ = x->Children_; - x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1; + y->Children_ = x->Children_; + x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1; } template <class TDummy> @@ -564,8 +564,8 @@ void TRbGlobal<TDummy>::RotateRight(TRbTreeNodeBase* x, TRbTreeNodeBase*& root) x->Parent_->Left_ = y; y->Right_ = x; x->Parent_ = y; - y->Children_ = x->Children_; - x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1; + y->Children_ = x->Children_; + x->Children_ = ((x->Left_) ? x->Left_->Children_ : 0) + ((x->Right_) ? x->Right_->Children_ : 0) + 1; } template <class TDummy> |