aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authoraosipenko <aosipenko@yandex-team.ru>2022-02-10 16:48:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:08 +0300
commit69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util/generic
parent948fd24d47d4b3b7815aaef1686aea00ef3f4288 (diff)
downloadydb-69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f.tar.gz
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/algorithm.h10
-rw-r--r--util/generic/algorithm_ut.cpp8
-rw-r--r--util/generic/bitops.h4
-rw-r--r--util/generic/strbase.h12
-rw-r--r--util/generic/string.h32
-rw-r--r--util/generic/string_ut.cpp28
-rw-r--r--util/generic/string_ut.h52
-rw-r--r--util/generic/ymath.cpp34
-rw-r--r--util/generic/ymath.h16
-rw-r--r--util/generic/ymath_ut.cpp38
10 files changed, 117 insertions, 117 deletions
diff --git a/util/generic/algorithm.h b/util/generic/algorithm.h
index 88f6e25021..badfb88993 100644
--- a/util/generic/algorithm.h
+++ b/util/generic/algorithm.h
@@ -337,11 +337,11 @@ void StableSortUniqueBy(C& c, const TGetKey& getKey) {
c.erase(UniqueBy(c.begin(), c.end(), getKey), c.end());
}
-template <class C, class TValue>
-void Erase(C& c, const TValue& value) {
- c.erase(std::remove(c.begin(), c.end(), value), c.end());
-}
-
+template <class C, class TValue>
+void Erase(C& c, const TValue& value) {
+ c.erase(std::remove(c.begin(), c.end(), value), c.end());
+}
+
template <class C, class P>
void EraseIf(C& c, P p) {
c.erase(std::remove_if(c.begin(), c.end(), p), c.end());
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp
index 7cb719d3b1..8d732fcc0c 100644
--- a/util/generic/algorithm_ut.cpp
+++ b/util/generic/algorithm_ut.cpp
@@ -269,10 +269,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) {
Y_UNIT_TEST(EraseTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {5, 4, 2, 1, 0};
- Erase(data, 3);
- UNIT_ASSERT_EQUAL(data, expected);
- }
-
+ Erase(data, 3);
+ UNIT_ASSERT_EQUAL(data, expected);
+ }
+
Y_UNIT_TEST(EraseIfTest) {
TVector<int> data = {5, 4, 3, 2, 1, 0};
TVector<int> expected = {2, 1, 0};
diff --git a/util/generic/bitops.h b/util/generic/bitops.h
index 787a5bc69d..2db15fc59b 100644
--- a/util/generic/bitops.h
+++ b/util/generic/bitops.h
@@ -57,7 +57,7 @@ namespace NBitOps {
return (v >> 32ULL) | (v << 32ULL);
}
-#if defined(__GNUC__)
+#if defined(__GNUC__)
inline unsigned GetValueBitCountImpl(unsigned int value) noexcept {
Y_ASSERT(value); // because __builtin_clz* have undefined result for zero.
return std::numeric_limits<unsigned int>::digits - __builtin_clz(value);
@@ -88,7 +88,7 @@ namespace NBitOps {
}
#endif
-#if defined(__GNUC__)
+#if defined(__GNUC__)
inline unsigned CountTrailingZeroBitsImpl(unsigned int value) noexcept {
Y_ASSERT(value); // because __builtin_ctz* have undefined result for zero.
return __builtin_ctz(value);
diff --git a/util/generic/strbase.h b/util/generic/strbase.h
index 3b16c03c72..ab39fc7537 100644
--- a/util/generic/strbase.h
+++ b/util/generic/strbase.h
@@ -312,8 +312,8 @@ public:
inline bool StartsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(*Ptr(), ch);
- }
-
+ }
+
inline bool EndsWith(const TCharType* s, size_t n) const noexcept {
return EndsWith(Ptr(), Len(), s, n);
}
@@ -324,8 +324,8 @@ public:
inline bool EndsWith(TCharType ch) const noexcept {
return !empty() && TTraits::eq(Ptr()[Len() - 1], ch);
- }
-
+ }
+
template <typename TDerived2, typename TTraits2>
bool operator==(const TStringBase<TDerived2, TChar, TTraits2>& s2) const noexcept {
return equal(*this, s2);
@@ -473,8 +473,8 @@ public:
inline size_t rfind(const TStringView str, size_t pos = npos) const {
return AsStringView().rfind(str.data(), pos, str.size());
- }
-
+ }
+
//~~~~Contains~~~~
/**
* @returns Whether this string contains the provided substring.
diff --git a/util/generic/string.h b/util/generic/string.h
index dfbd626a4a..8cd8aa6917 100644
--- a/util/generic/string.h
+++ b/util/generic/string.h
@@ -266,22 +266,22 @@ public:
#endif
}
- using TBase::back;
-
+ using TBase::back;
+
inline reference back() noexcept {
Y_ASSERT(!this->empty());
#ifdef TSTRING_IS_STD_STRING
return Storage_.back();
#else
- if (Y_UNLIKELY(this->empty())) {
+ if (Y_UNLIKELY(this->empty())) {
return reference(*this, 0);
- }
+ }
return reference(*this, length() - 1);
#endif
- }
-
+ }
+
using TBase::front;
inline reference front() noexcept {
@@ -606,9 +606,9 @@ public:
}
TBasicString& assign(TCharType ch) {
- return assign(&ch, 1);
- }
-
+ return assign(&ch, 1);
+ }
+
TBasicString& assign(const TCharType* pc, size_t len) {
#if defined(address_sanitizer_enabled) || defined(thread_sanitizer_enabled)
pc = (const TCharType*)HidePointerOrigin((void*)pc);
@@ -704,9 +704,9 @@ public:
TBasicString& operator=(std::nullptr_t) = delete;
TBasicString& operator=(TExplicitType<TCharType> ch) {
- return assign(ch);
- }
-
+ return assign(ch);
+ }
+
inline void reserve(size_t len) {
MutRef().reserve(len);
}
@@ -931,12 +931,12 @@ public:
friend TBasicString operator+(const TBasicStringBuf<TCharType, TTraits> s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT {
return Join(s1, s2);
- }
-
+ }
+
friend TBasicString operator+(const TCharType* s1, const TBasicString& s2) Y_WARN_UNUSED_RESULT {
return Join(s1, s2);
- }
-
+ }
+
friend TBasicString operator+(std::basic_string<TCharType, TTraits> l, TBasicString r) {
return l + r.ConstRef();
}
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index 86fc6aef99..ac82e9091d 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -740,11 +740,11 @@ public:
UNIT_TEST(TestJoin);
UNIT_TEST(TestCopy);
UNIT_TEST(TestStrCpy);
- UNIT_TEST(TestPrefixSuffix);
+ UNIT_TEST(TestPrefixSuffix);
#ifndef TSTRING_IS_STD_STRING
UNIT_TEST(TestCharRef);
#endif
- UNIT_TEST(TestBack)
+ UNIT_TEST(TestBack)
UNIT_TEST(TestFront)
UNIT_TEST(TestIterators);
UNIT_TEST(TestReverseIterators);
@@ -794,7 +794,7 @@ public:
UNIT_TEST(TestFind);
UNIT_TEST(TestContains);
UNIT_TEST(TestOperators);
- UNIT_TEST(TestLetOperator)
+ UNIT_TEST(TestLetOperator)
UNIT_TEST(TestMulOperators);
UNIT_TEST(TestFuncs);
UNIT_TEST(TestUtils);
@@ -802,11 +802,11 @@ public:
UNIT_TEST(TestJoin);
UNIT_TEST(TestCopy);
UNIT_TEST(TestStrCpy);
- UNIT_TEST(TestPrefixSuffix);
+ UNIT_TEST(TestPrefixSuffix);
#ifndef TSTRING_IS_STD_STRING
UNIT_TEST(TestCharRef);
#endif
- UNIT_TEST(TestBack);
+ UNIT_TEST(TestBack);
UNIT_TEST(TestFront)
UNIT_TEST(TestDecodingMethods);
UNIT_TEST(TestIterators);
@@ -881,20 +881,20 @@ private:
s2.AppendUtf8(text);
UNIT_ASSERT(testAppend == s2);
}
-
- void TestLetOperator() {
+
+ void TestLetOperator() {
TUtf16String str;
-
+
str = wchar16('X');
UNIT_ASSERT(str == TUtf16String::FromAscii("X"));
-
+
const TUtf16String hello = TUtf16String::FromAscii("hello");
str = hello.data();
- UNIT_ASSERT(str == hello);
-
- str = hello;
- UNIT_ASSERT(str == hello);
- }
+ UNIT_ASSERT(str == hello);
+
+ str = hello;
+ UNIT_ASSERT(str == hello);
+ }
void TestStringLiterals() {
TUtf16String s1 = u"hello";
diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h
index 518e6d10ea..44bb10bdeb 100644
--- a/util/generic/string_ut.h
+++ b/util/generic/string_ut.h
@@ -699,20 +699,20 @@ public:
const TStringType rs = Data._0123401234();
UNIT_ASSERT(rs.rfind(*Data._3()) == 8);
-
+
const TStringType empty;
- UNIT_ASSERT(empty.find(empty) == 0);
- UNIT_ASSERT(s.find(empty, 0) == 0);
- UNIT_ASSERT(s.find(empty, 1) == 1);
- UNIT_ASSERT(s.find(empty, s.length()) == s.length());
+ UNIT_ASSERT(empty.find(empty) == 0);
+ UNIT_ASSERT(s.find(empty, 0) == 0);
+ UNIT_ASSERT(s.find(empty, 1) == 1);
+ UNIT_ASSERT(s.find(empty, s.length()) == s.length());
UNIT_ASSERT(s.find(empty, s.length() + 1) == TStringType::npos);
-
- UNIT_ASSERT(s.rfind(empty) == s.length());
- UNIT_ASSERT(empty.rfind(empty) == 0);
+
+ UNIT_ASSERT(s.rfind(empty) == s.length());
+ UNIT_ASSERT(empty.rfind(empty) == 0);
UNIT_ASSERT(empty.rfind(s) == TStringType::npos);
-
+
UNIT_ASSERT(s2.rfind(s) == TStringType::npos);
- UNIT_ASSERT(s.rfind(s2) == 0);
+ UNIT_ASSERT(s.rfind(s2) == 0);
UNIT_ASSERT(s.rfind(TStringType(Data._345())) == 10);
UNIT_ASSERT(s.rfind(TStringType(Data._345()), 13) == 10);
UNIT_ASSERT(s.rfind(TStringType(Data._345()), 10) == 10);
@@ -736,7 +736,7 @@ public:
UNIT_ASSERT(s.Contains(empty));
UNIT_ASSERT(!empty.Contains(s));
UNIT_ASSERT(empty.Contains(empty));
- UNIT_ASSERT(s.Contains(empty, s.length()));
+ UNIT_ASSERT(s.Contains(empty, s.length()));
}
// Operators
@@ -885,9 +885,9 @@ public:
s2.assign(Data._0123456(), 4);
UNIT_ASSERT(s2 == Data._0123());
- s2.assign('1');
- UNIT_ASSERT(s2 == Data._1());
-
+ s2.assign('1');
+ UNIT_ASSERT(s2 == Data._1());
+
s2.assign(Data._0123456());
UNIT_ASSERT(s2 == Data._0123456());
@@ -978,8 +978,8 @@ public:
UNIT_ASSERT_EQUAL(data[4], 0);
}
}
-
- void TestPrefixSuffix() {
+
+ void TestPrefixSuffix() {
const TStringType emptyStr;
UNIT_ASSERT_EQUAL(emptyStr.StartsWith('x'), false);
UNIT_ASSERT_EQUAL(emptyStr.EndsWith('x'), false);
@@ -987,7 +987,7 @@ public:
UNIT_ASSERT_EQUAL(emptyStr.EndsWith(0), false);
UNIT_ASSERT_EQUAL(emptyStr.StartsWith(emptyStr), true);
UNIT_ASSERT_EQUAL(emptyStr.EndsWith(emptyStr), true);
-
+
const char_type chars[] = {'h', 'e', 'l', 'l', 'o', 0};
const TStringType str(chars);
UNIT_ASSERT_EQUAL(str.StartsWith('h'), true);
@@ -996,7 +996,7 @@ public:
UNIT_ASSERT_EQUAL(str.EndsWith('h'), false);
UNIT_ASSERT_EQUAL(str.StartsWith(emptyStr), true);
UNIT_ASSERT_EQUAL(str.EndsWith(emptyStr), true);
- }
+ }
#ifndef TSTRING_IS_STD_STRING
void TestCharRef() {
@@ -1046,20 +1046,20 @@ public:
}
}
#endif
-
- void TestBack() {
- const char_type chars[] = {'f', 'o', 'o', 0};
-
+
+ void TestBack() {
+ const char_type chars[] = {'f', 'o', 'o', 0};
+
TStringType str = chars;
const TStringType constStr = str;
-
+
UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o');
UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'o');
-
- str.back() = 'r';
+
+ str.back() = 'r';
UNIT_ASSERT_VALUES_EQUAL(constStr.back(), (ui8)'o');
UNIT_ASSERT_VALUES_EQUAL(str.back(), (ui8)'r');
- }
+ }
void TestFront() {
const char_type chars[] = {'f', 'o', 'o', 0};
diff --git a/util/generic/ymath.cpp b/util/generic/ymath.cpp
index ec83f696f7..31270728f4 100644
--- a/util/generic/ymath.cpp
+++ b/util/generic/ymath.cpp
@@ -1,5 +1,5 @@
-#include "ymath.h"
-
+#include "ymath.h"
+
double Exp2(double x) {
return pow(2.0, x);
}
@@ -9,23 +9,23 @@ float Exp2f(float x) {
}
#ifdef _MSC_VER
-
-double Erf(double x) {
+
+double Erf(double x) {
static constexpr double _M_2_SQRTPI = 1.12837916709551257390;
static constexpr double eps = 1.0e-7;
- if (fabs(x) >= 3.75)
- return x > 0 ? 1.0 : -1.0;
- double r = _M_2_SQRTPI * x;
- double f = r;
- for (int i = 1;; ++i) {
- r *= -x * x / i;
- f += r / (2 * i + 1);
- if (fabs(r) < eps * (2 * i + 1))
- break;
- }
- return f;
-}
-
+ if (fabs(x) >= 3.75)
+ return x > 0 ? 1.0 : -1.0;
+ double r = _M_2_SQRTPI * x;
+ double f = r;
+ for (int i = 1;; ++i) {
+ r *= -x * x / i;
+ f += r / (2 * i + 1);
+ if (fabs(r) < eps * (2 * i + 1))
+ break;
+ }
+ return f;
+}
+
#endif // _MSC_VER
double LogGammaImpl(double x) {
diff --git a/util/generic/ymath.h b/util/generic/ymath.h
index 97abaf6e31..9ff9ae2abe 100644
--- a/util/generic/ymath.h
+++ b/util/generic/ymath.h
@@ -1,7 +1,7 @@
#pragma once
#include <util/system/yassert.h>
-#include <util/system/defaults.h>
+#include <util/system/defaults.h>
#include <cmath>
#include <cfloat>
@@ -91,14 +91,14 @@ static inline bool IsNan(double f) {
inline bool IsValidFloat(double f) {
return IsFinite(f) && !IsNan(f);
}
-
+
#ifdef _MSC_VER
-double Erf(double x);
-#else
-inline double Erf(double x) {
- return erf(x);
-}
-#endif
+double Erf(double x);
+#else
+inline double Erf(double x) {
+ return erf(x);
+}
+#endif
/**
* @returns Natural logarithm of the absolute value
diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp
index 8861c05dcd..29190b55eb 100644
--- a/util/generic/ymath_ut.cpp
+++ b/util/generic/ymath_ut.cpp
@@ -123,32 +123,32 @@ void TMathTest::TestClp2() {
}
}
}
-
-void TMathTest::TestErf() {
- static const double a = -5.0;
+
+void TMathTest::TestErf() {
+ static const double a = -5.0;
static const double b = 5.0;
- static const int n = 50;
- static const double step = (b - a) / n;
-
- static const double values[n + 1] = {
- -1.0000000, -1.0000000, -1.0000000, -1.0000000, -1.0000000,
- -1.0000000, -0.9999999, -0.9999996, -0.9999985, -0.9999940,
- -0.9999779, -0.9999250, -0.9997640, -0.9993115, -0.9981372,
- -0.9953223, -0.9890905, -0.9763484, -0.9522851, -0.9103140,
- -0.8427008, -0.7421010, -0.6038561, -0.4283924, -0.2227026,
+ static const int n = 50;
+ static const double step = (b - a) / n;
+
+ static const double values[n + 1] = {
+ -1.0000000, -1.0000000, -1.0000000, -1.0000000, -1.0000000,
+ -1.0000000, -0.9999999, -0.9999996, -0.9999985, -0.9999940,
+ -0.9999779, -0.9999250, -0.9997640, -0.9993115, -0.9981372,
+ -0.9953223, -0.9890905, -0.9763484, -0.9522851, -0.9103140,
+ -0.8427008, -0.7421010, -0.6038561, -0.4283924, -0.2227026,
0.0000000,
0.2227026, 0.4283924, 0.6038561, 0.7421010, 0.8427008,
0.9103140, 0.9522851, 0.9763484, 0.9890905, 0.9953223,
0.9981372, 0.9993115, 0.9997640, 0.9999250, 0.9999779,
0.9999940, 0.9999985, 0.9999996, 0.9999999, 1.0000000,
1.0000000, 1.0000000, 1.0000000, 1.0000000, 1.0000000};
-
- double x = a;
- for (int i = 0; i <= n; ++i, x += step) {
- double f = Erf(x);
- UNIT_ASSERT_DOUBLES_EQUAL(f, values[i], 1e-7);
- }
-}
+
+ double x = a;
+ for (int i = 0; i <= n; ++i, x += step) {
+ double f = Erf(x);
+ UNIT_ASSERT_DOUBLES_EQUAL(f, values[i], 1e-7);
+ }
+}
void TMathTest::TestLogGamma() {
double curVal = 0.0;