aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorhippskill <hippskill@yandex-team.ru>2022-02-10 16:50:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:50:12 +0300
commitbd077d09a08e659195376ee97dc24728bb554246 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic
parent6362c4a2681cc317ffd22633d773f02de0d13697 (diff)
downloadydb-bd077d09a08e659195376ee97dc24728bb554246.tar.gz
Restoring authorship annotation for <hippskill@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/array_ref.h2
-rw-r--r--util/generic/iterator.h52
-rw-r--r--util/generic/iterator_ut.cpp84
3 files changed, 69 insertions, 69 deletions
diff --git a/util/generic/array_ref.h b/util/generic/array_ref.h
index a224443bfd2..1ac60ac7d3c 100644
--- a/util/generic/array_ref.h
+++ b/util/generic/array_ref.h
@@ -73,7 +73,7 @@ public:
{
}
- template <class TT, typename = std::enable_if_t<std::is_same<std::remove_const_t<T>, std::remove_const_t<TT>>::value>>
+ template <class TT, typename = std::enable_if_t<std::is_same<std::remove_const_t<T>, std::remove_const_t<TT>>::value>>
bool operator==(const TArrayRef<TT>& other) const noexcept {
return (S_ == other.size()) && std::equal(begin(), end(), other.begin());
}
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index aa141c2d5f8..19e9d20976d 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -5,30 +5,30 @@
namespace NStlIterator {
template <class T>
- class TProxy {
- public:
- TProxy() = default;
+ class TProxy {
+ public:
+ TProxy() = default;
TProxy(T&& value)
: Value_(std::move(value))
{
- }
+ }
- const T* operator->() const noexcept {
- return &Value_;
- }
+ const T* operator->() const noexcept {
+ return &Value_;
+ }
- const T& operator*() const noexcept {
- return Value_;
- }
+ const T& operator*() const noexcept {
+ return Value_;
+ }
- bool operator==(const TProxy& rhs) const {
- return Value_ == rhs.Value_;
+ bool operator==(const TProxy& rhs) const {
+ return Value_ == rhs.Value_;
}
- private:
- T Value_;
+ private:
+ T Value_;
};
-} // namespace NStlIterator
+} // namespace NStlIterator
/**
* Range adaptor that turns a derived class with a Java-style iteration
@@ -71,9 +71,9 @@ public: // TODO: private
static constexpr bool IsNoexceptNext = noexcept(std::declval<TSlave>().Next());
using difference_type = std::ptrdiff_t;
- using pointer = decltype(std::declval<TSlave>().Next());
- using reference = decltype(*std::declval<TSlave>().Next());
- using value_type = std::remove_cv_t<std::remove_reference_t<reference>>;
+ using pointer = decltype(std::declval<TSlave>().Next());
+ using reference = decltype(*std::declval<TSlave>().Next());
+ using value_type = std::remove_cv_t<std::remove_reference_t<reference>>;
using iterator_category = std::input_iterator_tag;
inline TIterator() noexcept
@@ -97,11 +97,11 @@ public: // TODO: private
}
inline pointer operator->() const noexcept {
- return Cur_;
+ return Cur_;
}
inline reference operator*() const noexcept {
- return *Cur_;
+ return *Cur_;
}
inline TIterator& operator++() noexcept(IsNoexceptNext) {
@@ -112,18 +112,18 @@ public: // TODO: private
private:
TSlave* Slave_;
- pointer Cur_;
+ pointer Cur_;
};
public:
- using const_iterator = TIterator;
- using iterator = const_iterator;
-
- inline iterator begin() const noexcept(TIterator::IsNoexceptNext) {
+ using const_iterator = TIterator;
+ using iterator = const_iterator;
+
+ inline iterator begin() const noexcept(TIterator::IsNoexceptNext) {
return TIterator(const_cast<TSlave*>(static_cast<const TSlave*>(this)));
}
- inline iterator end() const noexcept {
+ inline iterator end() const noexcept {
return TIterator();
}
};
diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp
index 5dc085c8214..00be19e10ec 100644
--- a/util/generic/iterator_ut.cpp
+++ b/util/generic/iterator_ut.cpp
@@ -9,55 +9,55 @@ Y_UNIT_TEST_SUITE(TIterator) {
UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin());
}
}
-
-Y_UNIT_TEST_SUITE(TInputRangeAdaptor) {
+
+Y_UNIT_TEST_SUITE(TInputRangeAdaptor) {
class TSquaresGenerator: public TInputRangeAdaptor<TSquaresGenerator> {
- public:
- const i64* Next() {
- Current_ = State_ * State_;
- ++State_;
- // Never return nullptr => we have infinite range!
- return &Current_;
- }
-
- private:
- i64 State_ = 0.0;
- i64 Current_ = 0.0;
- };
-
- Y_UNIT_TEST(TSquaresGenerator) {
- i64 cur = 0;
- for (i64 sqr : TSquaresGenerator{}) {
- UNIT_ASSERT_VALUES_EQUAL(cur * cur, sqr);
-
- if (++cur > 10) {
- break;
- }
- }
- }
-
+ public:
+ const i64* Next() {
+ Current_ = State_ * State_;
+ ++State_;
+ // Never return nullptr => we have infinite range!
+ return &Current_;
+ }
+
+ private:
+ i64 State_ = 0.0;
+ i64 Current_ = 0.0;
+ };
+
+ Y_UNIT_TEST(TSquaresGenerator) {
+ i64 cur = 0;
+ for (i64 sqr : TSquaresGenerator{}) {
+ UNIT_ASSERT_VALUES_EQUAL(cur * cur, sqr);
+
+ if (++cur > 10) {
+ break;
+ }
+ }
+ }
+
class TUrlPart: public TInputRangeAdaptor<TUrlPart> {
- public:
+ public:
TUrlPart(const TStringBuf& url)
: Url_(url)
{
- }
-
- NStlIterator::TProxy<TStringBuf> Next() {
- return Url_.NextTok('/');
- }
-
- private:
- TStringBuf Url_;
- };
-
- Y_UNIT_TEST(TUrlPart) {
+ }
+
+ NStlIterator::TProxy<TStringBuf> Next() {
+ return Url_.NextTok('/');
+ }
+
+ private:
+ TStringBuf Url_;
+ };
+
+ Y_UNIT_TEST(TUrlPart) {
const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")};
- auto expected_part = expected.begin();
+ auto expected_part = expected.begin();
for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) {
UNIT_ASSERT_VALUES_EQUAL(part, *expected_part);
++expected_part;
- }
+ }
UNIT_ASSERT(expected_part == expected.end());
- }
-}
+ }
+}