aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authordanlark <danlark@yandex-team.ru>2022-02-10 16:46:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:08 +0300
commit3426a9bc7f169ae9da54cef557ad2a33f6e8eee0 (patch)
tree26154e1e9990f1bb4525d3e3fb5b6dac2c2c1da2 /util/generic
parentcb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (diff)
downloadydb-3426a9bc7f169ae9da54cef557ad2a33f6e8eee0.tar.gz
Restoring authorship annotation for <danlark@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/algorithm.h22
-rw-r--r--util/generic/algorithm_ut.cpp66
-rw-r--r--util/generic/bitops.h38
-rw-r--r--util/generic/bitops_ut.cpp16
-rw-r--r--util/generic/buffer.h24
-rw-r--r--util/generic/buffer_ut.cpp26
-rw-r--r--util/generic/function.h38
-rw-r--r--util/generic/guid.cpp4
-rw-r--r--util/generic/is_in_ut.cpp6
-rw-r--r--util/generic/iterator_range.h26
-rw-r--r--util/generic/iterator_range_ut.cpp36
-rw-r--r--util/generic/strbase.h2
-rw-r--r--util/generic/strbuf.h4
-rw-r--r--util/generic/strbuf_ut.cpp18
-rw-r--r--util/generic/string.cpp2
-rw-r--r--util/generic/string_ut.cpp18
-rw-r--r--util/generic/string_ut.h14
-rw-r--r--util/generic/vector_ut.cpp14
18 files changed, 187 insertions, 187 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index badfb88993..0b24a74a92 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -347,17 +347,17 @@ void EraseIf(C& c, P p) {
c.erase(std::remove_if(c.begin(), c.end(), p), c.end());
}
-template <class C, class P>
-void EraseNodesIf(C& c, P p) {
- for (auto iter = c.begin(), last = c.end(); iter != last;) {
- if (p(*iter)) {
- c.erase(iter++);
- } else {
- ++iter;
- }
- }
-}
-
+template <class C, class P>
+void EraseNodesIf(C& c, P p) {
+ for (auto iter = c.begin(), last = c.end(); iter != last;) {
+ if (p(*iter)) {
+ c.erase(iter++);
+ } else {
+ ++iter;
+ }
+ }
+}
+
template <class T1, class T2>
static inline bool Equal(T1 f1, T1 l1, T2 f2) {
return std::equal(f1, l1, f2);
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 8d732fcc0c..0925eb354d 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -281,37 +281,37 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
}
Y_UNIT_TEST(EraseNodesIfTest) {
- TMap<int, int> map{{1, 1}, {2, 2}, {3, 5}};
- TMap<int, int> expectedMap{{1, 1}};
- EraseNodesIf(map, [](auto p) { return p.first >= 2; });
- UNIT_ASSERT_EQUAL(map, expectedMap);
-
- TMultiMap<int, int> multiMap{{1, 1}, {1, 3}, {2, 2}, {3, 5}};
- TMultiMap<int, int> expectedMultiMap{{1, 1}, {1, 3}};
- EraseNodesIf(multiMap, [](auto p) { return p.first >= 2; });
- UNIT_ASSERT_EQUAL(multiMap, expectedMultiMap);
-
- TSet<int> set{1, 2, 3, 4, 5, 6, 7};
- TSet<int> expectedSet{1, 3, 5, 7};
- EraseNodesIf(set, [](int i) { return i % 2 == 0; });
- UNIT_ASSERT_EQUAL(set, expectedSet);
-
- TMultiSet<int> multiSet{1, 1, 2, 3, 4, 4, 4, 5, 5, 5, 6, 7};
- TMultiSet<int> expectedMultiSet{1, 1, 3, 5, 5, 5, 7};
- EraseNodesIf(multiSet, [](int i) { return i % 2 == 0; });
- UNIT_ASSERT_EQUAL(multiSet, expectedMultiSet);
-
- THashMap<int, int> hashMap{{1, 0}, {3, 0}, {4, 0}, {10, 0}, {2, 0}, {5, 2}};
- THashMap<int, int> expectedHashMap{{1, 0}, {3, 0}, {5, 2}};
- EraseNodesIf(hashMap, [](auto p) { return p.first % 2 == 0; });
- UNIT_ASSERT_EQUAL(hashMap, expectedHashMap);
-
- THashMultiMap<int, int> hashMultiMap{{1, 0}, {3, 0}, {4, 0}, {10, 0}, {2, 0}, {5, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 2}};
- THashMultiMap<int, int> expectedHashMultiMap{{1, 0}, {1, 0}, {1, 0}, {3, 0}, {5, 0}};
- EraseNodesIf(hashMultiMap, [](auto p) { return p.first % 2 == 0; });
- UNIT_ASSERT_EQUAL(hashMultiMap, expectedHashMultiMap);
- }
-
+ TMap<int, int> map{{1, 1}, {2, 2}, {3, 5}};
+ TMap<int, int> expectedMap{{1, 1}};
+ EraseNodesIf(map, [](auto p) { return p.first >= 2; });
+ UNIT_ASSERT_EQUAL(map, expectedMap);
+
+ TMultiMap<int, int> multiMap{{1, 1}, {1, 3}, {2, 2}, {3, 5}};
+ TMultiMap<int, int> expectedMultiMap{{1, 1}, {1, 3}};
+ EraseNodesIf(multiMap, [](auto p) { return p.first >= 2; });
+ UNIT_ASSERT_EQUAL(multiMap, expectedMultiMap);
+
+ TSet<int> set{1, 2, 3, 4, 5, 6, 7};
+ TSet<int> expectedSet{1, 3, 5, 7};
+ EraseNodesIf(set, [](int i) { return i % 2 == 0; });
+ UNIT_ASSERT_EQUAL(set, expectedSet);
+
+ TMultiSet<int> multiSet{1, 1, 2, 3, 4, 4, 4, 5, 5, 5, 6, 7};
+ TMultiSet<int> expectedMultiSet{1, 1, 3, 5, 5, 5, 7};
+ EraseNodesIf(multiSet, [](int i) { return i % 2 == 0; });
+ UNIT_ASSERT_EQUAL(multiSet, expectedMultiSet);
+
+ THashMap<int, int> hashMap{{1, 0}, {3, 0}, {4, 0}, {10, 0}, {2, 0}, {5, 2}};
+ THashMap<int, int> expectedHashMap{{1, 0}, {3, 0}, {5, 2}};
+ EraseNodesIf(hashMap, [](auto p) { return p.first % 2 == 0; });
+ UNIT_ASSERT_EQUAL(hashMap, expectedHashMap);
+
+ THashMultiMap<int, int> hashMultiMap{{1, 0}, {3, 0}, {4, 0}, {10, 0}, {2, 0}, {5, 0}, {1, 0}, {1, 0}, {2, 0}, {2, 2}};
+ THashMultiMap<int, int> expectedHashMultiMap{{1, 0}, {1, 0}, {1, 0}, {3, 0}, {5, 0}};
+ EraseNodesIf(hashMultiMap, [](auto p) { return p.first % 2 == 0; });
+ UNIT_ASSERT_EQUAL(hashMultiMap, expectedHashMultiMap);
+ }
+
Y_UNIT_TEST(NthElementTest) {
{
TVector<TString> v;
@@ -551,7 +551,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
TVector<int>::iterator iter = CopyN(data, toCopy, result.begin());
UNIT_ASSERT_VALUES_EQUAL(iter - result.begin(), toCopy);
- UNIT_ASSERT_VALUES_EQUAL(result.size(), 10);
+ UNIT_ASSERT_VALUES_EQUAL(result.size(), 10);
for (size_t idx = 0; idx < toCopy; ++idx) {
UNIT_ASSERT_VALUES_EQUAL(data[idx], result[idx]);
}
@@ -582,7 +582,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
TVector<int> v(vSize, 0);
TVector<int>::iterator iter = CopyIf(data, data + count, v.begin(), [](int x) { return !(x % 3); });
- UNIT_ASSERT_VALUES_EQUAL(v.size(), vSize);
+ UNIT_ASSERT_VALUES_EQUAL(v.size(), vSize);
UNIT_ASSERT_VALUES_EQUAL(iter - v.begin(), 3);
v.resize(iter - v.begin());
for (size_t idx = 0; idx < v.size(); ++idx) {
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index 2db15fc59b..add0b75a17 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -424,31 +424,31 @@ constexpr T RotateBitsRightCT(T value, const ui8 shift) noexcept {
// do trick with mask to avoid undefined behaviour
return (value >> shift) | (value << ((-shift) & (sizeof(T) * 8 - 1)));
}
-
-/* Remain `size` bits to current `offset` of `value`
- size, offset are less than number of bits in size_type
- */
+
+/* Remain `size` bits to current `offset` of `value`
+ size, offset are less than number of bits in size_type
+ */
template <size_t Offset, size_t Size, class T>
-Y_FORCE_INLINE T SelectBits(T value) {
+Y_FORCE_INLINE T SelectBits(T value) {
static_assert(Size < sizeof(T) * 8, "violated: Size < sizeof(T) * 8");
static_assert(Offset < sizeof(T) * 8, "violated: Offset < sizeof(T) * 8");
- T id = 1;
- return (value >> Offset) & ((id << Size) - id);
-}
-
-/* Set `size` bits of `bits` to current offset of `value`. Requires that bits <= (1 << size) - 1
- size, offset are less than number of bits in size_type
- */
+ T id = 1;
+ return (value >> Offset) & ((id << Size) - id);
+}
+
+/* Set `size` bits of `bits` to current offset of `value`. Requires that bits <= (1 << size) - 1
+ size, offset are less than number of bits in size_type
+ */
template <size_t Offset, size_t Size, class T>
-void SetBits(T& value, T bits) {
+void SetBits(T& value, T bits) {
static_assert(Size < sizeof(T) * 8, "violated: Size < sizeof(T) * 8");
static_assert(Offset < sizeof(T) * 8, "violated: Offset < sizeof(T) * 8");
- T id = 1;
- T maxValue = ((id << Size) - id);
- Y_ASSERT(bits <= maxValue);
- value &= ~(maxValue << Offset);
- value |= bits << Offset;
-}
+ T id = 1;
+ T maxValue = ((id << Size) - id);
+ Y_ASSERT(bits <= maxValue);
+ value &= ~(maxValue << Offset);
+ value |= bits << Offset;
+}
inline constexpr ui64 NthBit64(int bit) {
return ui64(1) << bit;
diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp
index d23c2b5c27..0f7872b8b0 100644
--- a/util/generic/bitops_ut.cpp
+++ b/util/generic/bitops_ut.cpp
@@ -293,29 +293,29 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b1010000000000000000000000000000000000000000000000000000000000000u, 1), 0b0101000000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(RotateBitsRight<ui64>(0b0000000000000000000000000000000000000000000000000000000000000001u, 63), 0b0000000000000000000000000000000000000000000000000000000000000010u);
}
-
+
Y_UNIT_TEST(TestSelectBits) {
ui8 firstui8Test = SelectBits<3, 4, ui8>(0b11111111u);
ui8 secondui8Test = SelectBits<2, 5, ui8>(0b11101101u);
UNIT_ASSERT_VALUES_EQUAL(firstui8Test, 0b00001111u);
UNIT_ASSERT_VALUES_EQUAL(secondui8Test, 0b00011011u);
-
+
ui16 firstui16Test = SelectBits<9, 2, ui16>(0b1111111111111111u);
ui16 secondui16Test = SelectBits<3, 6, ui16>(0b1010011111010001u);
UNIT_ASSERT_VALUES_EQUAL(firstui16Test, 0b0000000000000011u);
UNIT_ASSERT_VALUES_EQUAL(secondui16Test, 0b0000000000111010u);
-
+
ui32 firstui32Test = SelectBits<23, 31, ui32>(0b11111111111111111111111111111111u);
ui32 secondui32Test = SelectBits<0, 31, ui32>(0b10001011101010011111010000111111u);
UNIT_ASSERT_VALUES_EQUAL(firstui32Test, 0b00000000000000000000000111111111u);
UNIT_ASSERT_VALUES_EQUAL(secondui32Test, 0b00001011101010011111010000111111);
-
+
ui64 firstui64Test = SelectBits<1, 62, ui64>(0b1111000000000000000000000000000000000000000000000000000000000000u);
ui64 secondui64Test = SelectBits<32, 43, ui64>(0b1111111111111111111111111111111111111111111111111111111111111111u);
UNIT_ASSERT_VALUES_EQUAL(firstui64Test, 0b0011100000000000000000000000000000000000000000000000000000000000u);
UNIT_ASSERT_VALUES_EQUAL(secondui64Test, 0b0000000000000000000000000000000011111111111111111111111111111111u);
}
-
+
Y_UNIT_TEST(TestSetBits) {
ui8 firstui8Test = 0b11111111u;
SetBits<3, 4, ui8>(firstui8Test, 0b00001111u);
@@ -323,21 +323,21 @@ Y_UNIT_TEST_SUITE(TBitOpsTest) {
SetBits<2, 7, ui8>(secondui8Test, 0b01110111u);
UNIT_ASSERT_VALUES_EQUAL(firstui8Test, 0b11111111u);
UNIT_ASSERT_VALUES_EQUAL(secondui8Test, 0b11011101u);
-
+
ui16 firstui16Test = 0b1111111111111111u;
SetBits<9, 4, ui16>(firstui16Test, 0b000000000000111u);
ui16 secondui16Test = 0b1010011111010001u;
SetBits<3, 15, ui16>(secondui16Test, 0b0010011111010001u);
UNIT_ASSERT_VALUES_EQUAL(firstui16Test, 0b1110111111111111u);
UNIT_ASSERT_VALUES_EQUAL(secondui16Test, 0b0011111010001001u);
-
+
ui32 firstui32Test = 0b11111111111111111111111111111111u;
SetBits<23, 31, ui32>(firstui32Test, 0b01100001111111111001111101111111u);
ui32 secondui32Test = 0b10001011101010011111010000111111u;
SetBits<0, 31, ui32>(secondui32Test, 0b01111111111111111111111111111111u);
UNIT_ASSERT_VALUES_EQUAL(firstui32Test, 0b10111111111111111111111111111111u);
UNIT_ASSERT_VALUES_EQUAL(secondui32Test, 0b11111111111111111111111111111111u);
-
+
ui64 firstui64Test = 0b1111000000000000000000000000000000000000000000000000000000000000u;
SetBits<1, 62, ui64>(firstui64Test, 0b0001000000000000000000000000000000000000000000000000000001010101u);
ui64 secondui64Test = 0b1111111111111111111111111111111111111111111111111111111111111111u;
diff --git a/util/generic/buffer.h b/util/generic/buffer.h
index 9576467404..38355d5258 100644
--- a/util/generic/buffer.h
+++ b/util/generic/buffer.h
@@ -181,18 +181,18 @@ public:
}
}
- inline char* data() noexcept {
- return Data();
- }
-
- inline const char* data() const noexcept {
- return Data();
- }
-
- inline size_t size() const noexcept {
- return Size();
- }
-
+ inline char* data() noexcept {
+ return Data();
+ }
+
+ inline const char* data() const noexcept {
+ return Data();
+ }
+
+ inline size_t size() const noexcept {
+ return Size();
+ }
+
inline void Swap(TBuffer& r) noexcept {
DoSwap(Data_, r.Data_);
DoSwap(Len_, r.Len_);
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp
index 437d7122ec..df500cf1eb 100644
--- a/util/generic/buffer_ut.cpp
+++ b/util/generic/buffer_ut.cpp
@@ -14,7 +14,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buf.Resize(6);
buf.EraseBack(2);
- UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), "1234");
+ UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), "1234");
}
Y_UNIT_TEST(TestAppend) {
@@ -32,7 +32,7 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
}
}
- UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str);
+ UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str);
}
Y_UNIT_TEST(TestReset) {
@@ -55,17 +55,17 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
TBuffer buf;
buf.Resize(10);
- UNIT_ASSERT_VALUES_EQUAL(buf.size(), 10u);
+ UNIT_ASSERT_VALUES_EQUAL(buf.size(), 10u);
buf.Resize(0);
- UNIT_ASSERT_VALUES_EQUAL(buf.size(), 0u);
+ UNIT_ASSERT_VALUES_EQUAL(buf.size(), 0u);
buf.Resize(9);
- memcpy(buf.data(), content, 9);
- UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some text");
+ memcpy(buf.data(), content, 9);
+ UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some text");
buf.Resize(4);
- UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some");
+ UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some");
}
Y_UNIT_TEST(TestReserve) {
@@ -92,12 +92,12 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
buf.Append('a');
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
TString tmp1 = "abcdef";
- buf.Append(tmp1.data(), tmp1.size());
+ buf.Append(tmp1.data(), tmp1.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 256);
TString tmp2 = "30498290sfokdsflj2308w";
buf.Resize(1020);
- buf.Append(tmp2.data(), tmp2.size());
+ buf.Append(tmp2.data(), tmp2.size());
UNIT_ASSERT_EQUAL(buf.Capacity(), 2048);
}
@@ -105,14 +105,14 @@ Y_UNIT_TEST_SUITE(TBufferTest) {
TBuffer buf;
TString content = "some text";
- buf.Append(content.data(), content.size());
+ buf.Append(content.data(), content.size());
UNIT_ASSERT_EQUAL(buf.Size(), 9);
UNIT_ASSERT_EQUAL(buf.Capacity(), 16);
buf.ShrinkToFit();
UNIT_ASSERT_EQUAL(buf.Size(), 9);
UNIT_ASSERT_EQUAL(buf.Capacity(), 9);
- UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), content);
+ UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), content);
const size_t MB = 1024 * 1024;
buf.Resize(MB);
@@ -184,10 +184,10 @@ Y_UNIT_TEST(TestSpeed) {
buf.Append("Some ", 5);
buf.Fill('!', 5);
buf.Append(" text.", 6);
- UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some !!!!! text.");
+ UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some !!!!! text.");
buf.Chop(5, 6);
- UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some text.");
+ UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some text.");
}
Y_UNIT_TEST(TestComparison) {
diff --git a/util/generic/function.h b/util/generic/function.h
index 62fa84e0cb..aa7bf8aa13 100644
--- a/util/generic/function.h
+++ b/util/generic/function.h
@@ -21,26 +21,26 @@ namespace NPrivate {
typedef R TSignature(Args...);
};
- template <class T>
- struct TRemoveNoExceptImpl {
- using Type = T;
- };
-
- template <typename R, typename... Args>
- struct TRemoveNoExceptImpl<R(Args...) noexcept> {
- using Type = R(Args...);
- };
-
- template <typename R, typename C, typename... Args>
- struct TRemoveNoExceptImpl<R (C::*)(Args...) noexcept> {
- using Type = R (C::*)(Args...);
- };
-
- template <class T>
- using TRemoveNoExcept = typename TRemoveNoExceptImpl<T>::Type;
-
+ template <class T>
+ struct TRemoveNoExceptImpl {
+ using Type = T;
+ };
+
+ template <typename R, typename... Args>
+ struct TRemoveNoExceptImpl<R(Args...) noexcept> {
+ using Type = R(Args...);
+ };
+
+ template <typename R, typename C, typename... Args>
+ struct TRemoveNoExceptImpl<R (C::*)(Args...) noexcept> {
+ using Type = R (C::*)(Args...);
+ };
+
+ template <class T>
+ using TRemoveNoExcept = typename TRemoveNoExceptImpl<T>::Type;
+
template <class F>
- using TRemoveClass = typename TRemoveClassImpl<TRemoveNoExcept<F>>::TSignature;
+ using TRemoveClass = typename TRemoveClassImpl<TRemoveNoExcept<F>>::TSignature;
template <class C>
struct TFuncInfo {
diff --git a/util/generic/guid.cpp b/util/generic/guid.cpp
index 8b907457bc..a0a25619bb 100644
--- a/util/generic/guid.cpp
+++ b/util/generic/guid.cpp
@@ -44,8 +44,8 @@ TGUID TGUID::Create() {
void CreateGuid(TGUID* res) {
ui64* dw = reinterpret_cast<ui64*>(res->dw);
- WriteUnaligned<ui64>(&dw[0], RandomNumber<ui64>());
- WriteUnaligned<ui64>(&dw[1], RandomNumber<ui64>());
+ WriteUnaligned<ui64>(&dw[0], RandomNumber<ui64>());
+ WriteUnaligned<ui64>(&dw[1], RandomNumber<ui64>());
}
TGUID TGUID::CreateTimebased() {
diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp
index c668bce807..4fc257797e 100644
--- a/util/generic/is_in_ut.cpp
+++ b/util/generic/is_in_ut.cpp
@@ -91,7 +91,7 @@ Y_UNIT_TEST_SUITE(TIsIn) {
const TStringBuf str = "abc////";
- UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3}));
+ UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf{str.data(), 3}));
}
Y_UNIT_TEST(ConfOfTest) {
@@ -100,8 +100,8 @@ Y_UNIT_TEST_SUITE(TIsIn) {
const TString b = "b";
- UNIT_ASSERT(!IsIn({"a", "b", "c"}, b.data())); // compares pointers by value. Whether it's good or not.
- UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), b.data()));
+ UNIT_ASSERT(!IsIn({"a", "b", "c"}, b.data())); // compares pointers by value. Whether it's good or not.
+ UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), b.data()));
UNIT_ASSERT(IsIn(TVector<TStringBuf>({"a", "b", "c"}), "b"));
}
diff --git a/util/generic/iterator_range.h b/util/generic/iterator_range.h
index 9f4d02da29..d89eaf7559 100644
--- a/util/generic/iterator_range.h
+++ b/util/generic/iterator_range.h
@@ -1,7 +1,7 @@
#pragma once
-#include <util/system/yassert.h>
-
+#include <util/system/yassert.h>
+
#include <iterator>
#include <utility>
@@ -43,10 +43,10 @@ class TIteratorRange<TIterator, TIterator> {
public:
using iterator = TIterator;
using const_iterator = TIterator;
- using value_type = typename std::iterator_traits<iterator>::value_type;
- using reference = typename std::iterator_traits<iterator>::reference;
- using const_reference = typename std::iterator_traits<const_iterator>::reference;
- using difference_type = typename std::iterator_traits<iterator>::difference_type;
+ using value_type = typename std::iterator_traits<iterator>::value_type;
+ using reference = typename std::iterator_traits<iterator>::reference;
+ using const_reference = typename std::iterator_traits<const_iterator>::reference;
+ using difference_type = typename std::iterator_traits<iterator>::difference_type;
using size_type = std::size_t;
TIteratorRange()
@@ -74,15 +74,15 @@ public:
}
size_type size() const {
- return End_ - Begin_;
- }
-
- reference operator[](size_t at) const {
- Y_ASSERT(at < size());
-
- return *(Begin_ + at);
+ return End_ - Begin_;
}
+ reference operator[](size_t at) const {
+ Y_ASSERT(at < size());
+
+ return *(Begin_ + at);
+ }
+
private:
TIterator Begin_;
TIterator End_;
diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp
index a7e3670ae1..a93dc2e119 100644
--- a/util/generic/iterator_range_ut.cpp
+++ b/util/generic/iterator_range_ut.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/algorithm.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
Y_UNIT_TEST_SUITE(IteratorRange) {
Y_UNIT_TEST(DefaultConstructor) {
@@ -70,24 +70,24 @@ Y_UNIT_TEST_SUITE(IteratorRange) {
Y_UNIT_TEST(OperatorsAndReferences) {
TVector<size_t> values{1, 2, 3, 4, 5};
- auto range = MakeIteratorRange(values.begin(), values.end());
- UNIT_ASSERT_VALUES_EQUAL(range[2], 3);
- UNIT_ASSERT_VALUES_EQUAL(range[range[2]], 4);
- *values.begin() = 100500;
- UNIT_ASSERT_VALUES_EQUAL(range[0], 100500);
- range[0] = 100501;
- UNIT_ASSERT_VALUES_EQUAL(range[0], 100501);
-
+ auto range = MakeIteratorRange(values.begin(), values.end());
+ UNIT_ASSERT_VALUES_EQUAL(range[2], 3);
+ UNIT_ASSERT_VALUES_EQUAL(range[range[2]], 4);
+ *values.begin() = 100500;
+ UNIT_ASSERT_VALUES_EQUAL(range[0], 100500);
+ range[0] = 100501;
+ UNIT_ASSERT_VALUES_EQUAL(range[0], 100501);
+
TVector<bool> valuesBool{false, true, false, false, false, false, true};
- auto rangeBVector = MakeIteratorRange(valuesBool.begin(), valuesBool.end());
- UNIT_ASSERT_VALUES_EQUAL(rangeBVector[1], true);
- rangeBVector[0] = true;
- valuesBool.back() = false;
- UNIT_ASSERT_VALUES_EQUAL(rangeBVector[0], true);
- UNIT_ASSERT_VALUES_EQUAL(rangeBVector[2], false);
- UNIT_ASSERT_VALUES_EQUAL(rangeBVector[6], false);
- }
-
+ auto rangeBVector = MakeIteratorRange(valuesBool.begin(), valuesBool.end());
+ UNIT_ASSERT_VALUES_EQUAL(rangeBVector[1], true);
+ rangeBVector[0] = true;
+ valuesBool.back() = false;
+ UNIT_ASSERT_VALUES_EQUAL(rangeBVector[0], true);
+ UNIT_ASSERT_VALUES_EQUAL(rangeBVector[2], false);
+ UNIT_ASSERT_VALUES_EQUAL(rangeBVector[6], false);
+ }
+
Y_UNIT_TEST(CanUseInAlgorithms) {
const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values));
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index ab39fc7537..7289e651ba 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -439,7 +439,7 @@ public:
}
inline TCharType operator[](size_t pos) const noexcept {
- Y_ASSERT(pos < this->size());
+ Y_ASSERT(pos < this->size());
return Ptr()[pos];
}
diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h
index 70b9360d58..595db8114c 100644
--- a/util/generic/strbuf.h
+++ b/util/generic/strbuf.h
@@ -214,7 +214,7 @@ public:
* @returns Whether the split was actually performed.
*/
inline bool TrySplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
- return TrySplitOn(TBase::find(delim), l, r, delim.size());
+ return TrySplitOn(TBase::find(delim), l, r, delim.size());
}
/**
@@ -229,7 +229,7 @@ public:
* @returns Whether the split was actually performed.
*/
inline bool TryRSplit(TdSelf delim, TdSelf& l, TdSelf& r) const noexcept {
- return TrySplitOn(TBase::rfind(delim), l, r, delim.size());
+ return TrySplitOn(TBase::rfind(delim), l, r, delim.size());
}
inline void Split(TCharType delim, TdSelf& l, TdSelf& r) const noexcept {
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 69cde785af..fe2f7f1913 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -8,14 +8,14 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
Y_UNIT_TEST(TestConstructorsAndOperators) {
TStringBuf str("qwerty");
- UNIT_ASSERT_EQUAL(*str.data(), 'q');
- UNIT_ASSERT_EQUAL(str.size(), 6);
+ UNIT_ASSERT_EQUAL(*str.data(), 'q');
+ UNIT_ASSERT_EQUAL(str.size(), 6);
TStringBuf str1("qwe\0rty"sv);
TStringBuf str2(str1.data());
UNIT_ASSERT_VALUES_UNEQUAL(str1, str2);
- UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
- UNIT_ASSERT_VALUES_EQUAL(str2.size(), 3);
+ UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
+ UNIT_ASSERT_VALUES_EQUAL(str2.size(), 3);
std::string_view helloWorld("Hello, World!");
TStringBuf fromStringView(helloWorld);
@@ -29,10 +29,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
Y_UNIT_TEST(TestConstExpr) {
static constexpr TStringBuf str1("qwe\0rty", 7);
- static constexpr TStringBuf str2(str1.data(), str1.size());
+ static constexpr TStringBuf str2(str1.data(), str1.size());
static constexpr TStringBuf str3 = "qwe\0rty"sv;
- UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
+ UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
UNIT_ASSERT_VALUES_EQUAL(str1, str2);
UNIT_ASSERT_VALUES_EQUAL(str2, str3);
@@ -136,7 +136,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
}
Y_UNIT_TEST(TestEmpty) {
- UNIT_ASSERT(TStringBuf().empty());
+ UNIT_ASSERT(TStringBuf().empty());
UNIT_ASSERT(!TStringBuf("q").empty());
}
@@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
str = qw;
str.Chop(10);
- UNIT_ASSERT(str.empty());
+ UNIT_ASSERT(str.empty());
str = qw;
UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty"));
@@ -172,7 +172,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
rt = qw;
lt = rt.NextTok('r');
TStringBuf ty = rt.NextTok('r'); // no 'r' in "ty"
- UNIT_ASSERT_EQUAL(rt.size(), 0);
+ UNIT_ASSERT_EQUAL(rt.size(), 0);
UNIT_ASSERT_EQUAL(ty, TStringBuf("ty"));
}
diff --git a/util/generic/string.cpp b/util/generic/string.cpp
index 3c655f1f66..584f72675e 100644
--- a/util/generic/string.cpp
+++ b/util/generic/string.cpp
@@ -11,7 +11,7 @@
alignas(32) const char NULL_STRING_REPR[128] = {0};
std::ostream& operator<<(std::ostream& os, const TString& s) {
- return os.write(s.data(), s.size());
+ return os.write(s.data(), s.size());
}
std::istream& operator>>(std::istream& is, TString& s) {
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index ac82e9091d..cd45b1d42c 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -29,7 +29,7 @@ public:
void TestZero() {
const char data[] = "abc\0def\0";
TString s(data, sizeof(data));
- UNIT_ASSERT(s.size() == sizeof(data));
+ UNIT_ASSERT(s.size() == sizeof(data));
UNIT_ASSERT(s.StartsWith(s));
UNIT_ASSERT(s.EndsWith(s));
UNIT_ASSERT(s.Contains('\0'));
@@ -48,7 +48,7 @@ public:
UNIT_ASSERT_EQUAL(TString::npos, s.find(TString(nonSubstring, sizeof(nonSubstring))));
TString copy = s;
- copy.replace(copy.size() - 1, 1, "z");
+ copy.replace(copy.size() - 1, 1, "z");
UNIT_ASSERT(s != copy);
copy.replace(copy.size() - 1, 1, "\0", 0, 1);
UNIT_ASSERT(s == copy);
@@ -57,8 +57,8 @@ public:
UNIT_ASSERT(s.StartsWith(prefix));
UNIT_ASSERT(s != prefix);
UNIT_ASSERT(s > prefix);
- UNIT_ASSERT(s > s.data());
- UNIT_ASSERT(s == TString(s.data(), s.size()));
+ UNIT_ASSERT(s > s.data());
+ UNIT_ASSERT(s == TString(s.data(), s.size()));
UNIT_ASSERT(data < s);
s.remove(5);
@@ -552,13 +552,13 @@ protected:
str2 = Data_.abcdef();
UNIT_ASSERT(str1.compare(str2) == 0);
- UNIT_ASSERT(str1.compare(str2.data(), str2.size()) == 0);
+ UNIT_ASSERT(str1.compare(str2.data(), str2.size()) == 0);
str2 = Data_.abcde();
UNIT_ASSERT(str1.compare(str2) > 0);
- UNIT_ASSERT(str1.compare(str2.data(), str2.size()) > 0);
+ UNIT_ASSERT(str1.compare(str2.data(), str2.size()) > 0);
str2 = Data_.abcdefg();
UNIT_ASSERT(str1.compare(str2) < 0);
- UNIT_ASSERT(str1.compare(str2.data(), str2.size()) < 0);
+ UNIT_ASSERT(str1.compare(str2.data(), str2.size()) < 0);
UNIT_ASSERT(str1.compare(Data_.abcdef()) == 0);
UNIT_ASSERT(str1.compare(Data_.abcde()) > 0);
@@ -889,7 +889,7 @@ private:
UNIT_ASSERT(str == TUtf16String::FromAscii("X"));
const TUtf16String hello = TUtf16String::FromAscii("hello");
- str = hello.data();
+ str = hello.data();
UNIT_ASSERT(str == hello);
str = hello;
@@ -1087,7 +1087,7 @@ private:
UNIT_ASSERT(str == TUtf32String::FromAscii("X"));
const TUtf32String hello = TUtf32String::FromAscii("hello");
- str = hello.data();
+ str = hello.data();
UNIT_ASSERT(str == hello);
str = hello;
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 44bb10bdeb..95bc855cb2 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -646,8 +646,8 @@ public:
s = Data._012345();
UNIT_ASSERT(s.at(1) == *Data._1());
UNIT_ASSERT(s[1] == *Data._1());
- UNIT_ASSERT(s.at(s.size()) == 0);
- UNIT_ASSERT(s[s.size()] == 0);
+ UNIT_ASSERT(s.at(s.size()) == 0);
+ UNIT_ASSERT(s[s.size()] == 0);
}
#ifndef TSTRING_IS_STD_STRING
@@ -690,7 +690,7 @@ public:
UNIT_ASSERT(s.find_first_of(TStringType(Data._389())) == 3);
UNIT_ASSERT(s.find_first_of(Data._389()) == 3);
- UNIT_ASSERT(s.find_first_of(Data._389(), s.size()) == TStringType::npos);
+ UNIT_ASSERT(s.find_first_of(Data._389(), s.size()) == TStringType::npos);
UNIT_ASSERT(s.find_first_not_of(Data._123()) == 0);
UNIT_ASSERT(s.find_first_of('6') == 6);
UNIT_ASSERT(s.find_first_of('1', 2) == 8);
@@ -820,10 +820,10 @@ public:
void TestFuncs() {
TStringType s(Data._0123456());
- UNIT_ASSERT(s.c_str() == s.data());
+ UNIT_ASSERT(s.c_str() == s.data());
// length()
- UNIT_ASSERT(s.length() == s.size());
+ UNIT_ASSERT(s.length() == s.size());
UNIT_ASSERT(s.length() == traits_type::length(s.data()));
// is_null()
@@ -868,10 +868,10 @@ public:
s2 = s3;
// resize family
- s2.resize(s2.size()); // without length change
+ s2.resize(s2.size()); // without length change
UNIT_ASSERT(s2 == Data.Asdf1234qwer());
- s2.resize(s2.size() + 4, *Data.W());
+ s2.resize(s2.size() + 4, *Data.W());
UNIT_ASSERT(s2 == Data.Asdf1234qwerWWWW());
s2.resize(4);
diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp
index 0f6b4037a0..865a00cd3a 100644
--- a/util/generic/vector_ut.cpp
+++ b/util/generic/vector_ut.cpp
@@ -70,7 +70,7 @@ private:
inline void TestTildeEmptyToNull() {
TVector<int> v;
- UNIT_ASSERT_EQUAL(nullptr, v.data());
+ UNIT_ASSERT_EQUAL(nullptr, v.data());
}
inline void TestTilde() {
@@ -78,17 +78,17 @@ private:
v.push_back(10);
v.push_back(20);
- UNIT_ASSERT_EQUAL(10, (v.data())[0]);
- UNIT_ASSERT_EQUAL(20, (v.data())[1]);
+ UNIT_ASSERT_EQUAL(10, (v.data())[0]);
+ UNIT_ASSERT_EQUAL(20, (v.data())[1]);
for (int i = 0; i < 10000; ++i) {
v.push_back(99);
}
- UNIT_ASSERT_EQUAL(10, (v.data())[0]);
- UNIT_ASSERT_EQUAL(20, (v.data())[1]);
- UNIT_ASSERT_EQUAL(99, (v.data())[3]);
- UNIT_ASSERT_EQUAL(99, (v.data())[4]);
+ UNIT_ASSERT_EQUAL(10, (v.data())[0]);
+ UNIT_ASSERT_EQUAL(20, (v.data())[1]);
+ UNIT_ASSERT_EQUAL(99, (v.data())[3]);
+ UNIT_ASSERT_EQUAL(99, (v.data())[4]);
}
// Copy-paste of STLPort tests