#pragma once #include "utils/iterator/count.hpp" #include "utils/option.hpp" class EdgeType; namespace iter { template auto make_map(I &&iter, OP &&op); template auto make_filter(I &&iter, OP &&op); template void for_all(I &&iter, C &&consumer); } // Base iterator for next() kind iterator. // T - type of return value template class IteratorBase { public: virtual ~IteratorBase(){}; virtual Option next() = 0; virtual Count count() { return Count(0, ~((size_t)0)); } template auto map(OP &&op) { return iter::make_map(std::move(*this), std::move(op)); } template auto filter(OP &&op) { return iter::make_filter( std::move(*this), std::move(op)); } // Maps with call to method to() and filters with call to fill. auto to() { return map([](auto er) { return er.to(); }).fill(); } // Filters with call to method fill() auto fill() { return filter([](auto &ra) { return ra.fill(); }); } // Filters with type template auto type(TYPE const &type) { return filter([&](auto &ra) { return ra.edge_type() == type; }); } // Filters out vertices which are connected. auto isolated() { return filter([&](auto &ra) { return ra.isolated(); }); } // For all items calls OP. template void for_all(OP &&op) { iter::for_all(std::move(*this), std::move(op)); } };