aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/iterator.h
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commitbf9e69a933f89af083d895185f01ed65e4d90766 (patch)
treeb2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/generic/iterator.h
parent863a59a65247c24db7cb06789bc5cf79d04da32f (diff)
downloadydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic/iterator.h')
-rw-r--r--util/generic/iterator.h84
1 files changed, 42 insertions, 42 deletions
diff --git a/util/generic/iterator.h b/util/generic/iterator.h
index 0d5587691c..19e9d20976 100644
--- a/util/generic/iterator.h
+++ b/util/generic/iterator.h
@@ -30,42 +30,42 @@ namespace NStlIterator {
};
} // namespace NStlIterator
-/**
- * Range adaptor that turns a derived class with a Java-style iteration
- * interface into an STL range.
- *
- * Derived class is expected to define:
- * \code
- * TSomething* Next();
- * \endcode
- *
- * `Next()` returning `nullptr` signals end of range. Note that you can also use
- * pointer-like types instead of actual pointers (e.g. `TAtomicSharedPtr`).
- *
- * Since iteration state is stored inside the derived class, the resulting range
- * is an input range (works for single pass algorithms only). Technically speaking,
- * if you're returning a non-const pointer from `Next`, it can also work as an output range.
- *
- * Example usage:
- * \code
- * class TSquaresGenerator: public TInputRangeAdaptor<TSquaresGenerator> {
- * public:
- * const double* Next() {
- * Current_ = State_ * State_;
- * State_ += 1.0;
- * // Never return nullptr => we have infinite range!
- * return &Current_;
- * }
- *
- * private:
- * double State_ = 0.0;
- * double Current_ = 0.0;
- * }
- * \endcode
- */
+/**
+ * Range adaptor that turns a derived class with a Java-style iteration
+ * interface into an STL range.
+ *
+ * Derived class is expected to define:
+ * \code
+ * TSomething* Next();
+ * \endcode
+ *
+ * `Next()` returning `nullptr` signals end of range. Note that you can also use
+ * pointer-like types instead of actual pointers (e.g. `TAtomicSharedPtr`).
+ *
+ * Since iteration state is stored inside the derived class, the resulting range
+ * is an input range (works for single pass algorithms only). Technically speaking,
+ * if you're returning a non-const pointer from `Next`, it can also work as an output range.
+ *
+ * Example usage:
+ * \code
+ * class TSquaresGenerator: public TInputRangeAdaptor<TSquaresGenerator> {
+ * public:
+ * const double* Next() {
+ * Current_ = State_ * State_;
+ * State_ += 1.0;
+ * // Never return nullptr => we have infinite range!
+ * return &Current_;
+ * }
+ *
+ * private:
+ * double State_ = 0.0;
+ * double Current_ = 0.0;
+ * }
+ * \endcode
+ */
template <class TSlave>
-class TInputRangeAdaptor {
-public: // TODO: private
+class TInputRangeAdaptor {
+public: // TODO: private
class TIterator {
public:
static constexpr bool IsNoexceptNext = noexcept(std::declval<TSlave>().Next());
@@ -74,7 +74,7 @@ public: // TODO: private
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;
+ using iterator_category = std::input_iterator_tag;
inline TIterator() noexcept
: Slave_(nullptr)
@@ -96,11 +96,11 @@ public: // TODO: private
return !(*this == it);
}
- inline pointer operator->() const noexcept {
+ inline pointer operator->() const noexcept {
return Cur_;
}
- inline reference operator*() const noexcept {
+ inline reference operator*() const noexcept {
return *Cur_;
}
@@ -128,12 +128,12 @@ public:
}
};
-/**
- * Transform given reverse iterator into forward iterator pointing to the same element.
+/**
+ * Transform given reverse iterator into forward iterator pointing to the same element.
*
- * @see http://stackoverflow.com/a/1830240
+ * @see http://stackoverflow.com/a/1830240
*/
template <class TIterator>
-auto ToForwardIterator(TIterator iter) {
+auto ToForwardIterator(TIterator iter) {
return std::next(iter).base();
}