aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/iterator.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/generic/iterator.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic/iterator.h')
-rw-r--r--util/generic/iterator.h104
1 files changed, 52 insertions, 52 deletions
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index 19e9d20976..88b4167e7d 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -1,35 +1,35 @@
#pragma once
-
+
#include <iterator>
#include <utility>
-namespace NStlIterator {
- template <class T>
+namespace NStlIterator {
+ template <class T>
class TProxy {
public:
TProxy() = default;
- TProxy(T&& value)
- : Value_(std::move(value))
- {
+ TProxy(T&& value)
+ : Value_(std::move(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_;
- }
-
+ }
+
private:
T Value_;
- };
+ };
} // namespace NStlIterator
-
+
/**
* Range adaptor that turns a derived class with a Java-style iteration
* interface into an STL range.
@@ -63,11 +63,11 @@ namespace NStlIterator {
* }
* \endcode
*/
-template <class TSlave>
+template <class TSlave>
class TInputRangeAdaptor {
public: // TODO: private
- class TIterator {
- public:
+ class TIterator {
+ public:
static constexpr bool IsNoexceptNext = noexcept(std::declval<TSlave>().Next());
using difference_type = std::ptrdiff_t;
@@ -77,56 +77,56 @@ public: // TODO: private
using iterator_category = std::input_iterator_tag;
inline TIterator() noexcept
- : Slave_(nullptr)
- , Cur_()
- {
- }
-
+ : Slave_(nullptr)
+ , Cur_()
+ {
+ }
+
inline TIterator(TSlave* slave) noexcept(IsNoexceptNext)
- : Slave_(slave)
- , Cur_(Slave_->Next())
- {
- }
-
+ : Slave_(slave)
+ , Cur_(Slave_->Next())
+ {
+ }
+
inline bool operator==(const TIterator& it) const noexcept {
- return Cur_ == it.Cur_;
- }
-
+ return Cur_ == it.Cur_;
+ }
+
inline bool operator!=(const TIterator& it) const noexcept {
- return !(*this == it);
- }
-
+ return !(*this == it);
+ }
+
inline pointer operator->() const noexcept {
return Cur_;
- }
-
+ }
+
inline reference operator*() const noexcept {
return *Cur_;
- }
-
+ }
+
inline TIterator& operator++() noexcept(IsNoexceptNext) {
- Cur_ = Slave_->Next();
-
- return *this;
- }
-
- private:
- TSlave* Slave_;
+ Cur_ = Slave_->Next();
+
+ return *this;
+ }
+
+ private:
+ TSlave* Slave_;
pointer Cur_;
- };
-
-public:
+ };
+
+public:
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)));
- }
-
+ return TIterator(const_cast<TSlave*>(static_cast<const TSlave*>(this)));
+ }
+
inline iterator end() const noexcept {
- return TIterator();
- }
-};
+ return TIterator();
+ }
+};
/**
* Transform given reverse iterator into forward iterator pointing to the same element.