|
Console Library 8.0.0
A header-only library that makes C++ simple
|
生成器模式头文件。 More...
#include <cmath>#include <cstdlib>#include <iterator>#include <type_traits>#include <utility>#include <vector>#include "../core/csexc.h"#include "../text/repr.h"#include "./iter.h"Go to the source code of this file.
Namespaces | |
| namespace | console |
| 本库所有组件所在的顶层命名空间。 | |
| namespace | console::gen |
| namespace | console::ops |
Functions | |
| template<class Derived, class T> | |
| Generator< Derived, T >::iterator | console::iter (Generator< Derived, T > &g) |
| 获取生成器迭代器的辅助函数。 | |
| template<class Derived, class T> | |
| T | console::next (typename Generator< Derived, T >::iterator &it) |
| 从迭代器获取下一个值的辅助函数。 | |
| template<class Derived, class T, class CharT = char, class Traits = std::char_traits<CharT>> | |
| std::basic_ostream< CharT, Traits > & | console::print_generator (std::basic_ostream< CharT, Traits > &os, const Generator< Derived, T > &gen) |
| 将 Generator 的内容输出到流,格式为 [elem1, elem2, ...]。 | |
| template<class Derived, class T, class CharT = char, class Traits = std::char_traits<CharT>> | |
| std::basic_ostream< CharT, Traits > & | console::operator<< (std::basic_ostream< CharT, Traits > &os, const Generator< Derived, T > &gen) |
| 输出 Generator 到流的 operator<< 重载。 | |
| template<class Iter> | |
| Views< Iter > | console::gen::views (Iter begin, Iter end) |
| 从迭代器范围创建视图生成器。 | |
| template<class Container> | |
| Views< typename Container::iterator > | console::gen::views (Container &container) |
| 从容器引用创建视图生成器。 | |
| template<class T> | |
| List< T > | console::gen::list (std::initializer_list< T > list) |
| 从初始化列表创建列表生成器。 | |
| template<class Iterator> | |
| List< typename std::decay< typename Iterator::value_type >::type > | console::gen::list (Iterator begin, Iterator end) |
| 从迭代器范围创建列表生成器。 | |
| template<class Container> | |
| List< typename Container::value_type > | console::gen::list (Container &container) |
| 从容器引用创建列表生成器。 | |
| template<class T> | |
| Range< T > | console::gen::range (T begin, T end, T step=1) |
| 创建范围生成器。 | |
| template<class T> | |
| Range< T > | console::gen::range (T end) |
| 创建范围生成器。 | |
| template<class T> | |
| Repeat< T > | console::gen::repeat (T val, size_t n) |
| 创建重复生成器。 | |
| template<class T> | |
| Repeat< T > | console::gen::repeat (T val) |
| 创建重复生成器。 | |
| template<class T> | |
| Cycle< T > | console::gen::cycle (std::initializer_list< T > list) |
| 创建循环生成器。 | |
| template<class Iterator> | |
| Cycle< typename std::decay< typename Iterator::value_type >::type > | console::gen::cycle (Iterator begin, Iterator end) |
| 创建循环生成器。 | |
| template<class Container> | |
| Cycle< typename Container::value_type > | console::gen::cycle (const Container &container) |
| 创建循环生成器。 | |
| template<class T> | |
| Counter< T > | console::gen::counter (T start=T{0}, T step=T{1}, size_t times=size_t(-1)) |
| 创建计数器生成器。 | |
| template<class Func> | |
| map_t< Func > | console::gen::map (Func f) |
| 创建映射适配器。 | |
| template<class Pred> | |
| filter_t< Pred > | console::gen::filter (Pred pred) |
| 创建过滤适配器。 | |
| take_t | console::gen::take (size_t n) |
| 创建取前n个元素适配器。 | |
| drop_t | console::gen::drop (size_t n) |
| 创建跳过前n个元素适配器。 | |
| template<class Func> | |
| Generate< Func > | console::gen::generate (Func func) |
| 创建生成器适配器。 | |
| template<class Gen1, class Gen2> | |
| Zip< typename std::decay< Gen1 >::type, typename std::decay< Gen2 >::type > | console::gen::zip (Gen1 &&g1, Gen2 &&g2) |
| 压缩两个生成器。 | |
| template<class Pred> | |
| take_while_t< Pred > | console::gen::take_while (Pred pred) |
| 创建取前若干个元素适配器。 | |
| template<class Pred> | |
| drop_while_t< Pred > | console::gen::drop_while (Pred pred) |
| 创建跳过前若干个元素适配器。 | |
| template<class Iterator> | |
| to_t< Iterator > | console::gen::to (Iterator it) |
| 创建目标迭代器适配器。 | |
| template<class Gen1, class Gen2> | |
| auto | console::gen::operator& (Gen1 &&g1, Gen2 &&g2) -> decltype(gen::zip(std::forward< Gen1 >(g1), std::forward< Gen2 >(g2))) |
| 按位与操作符重载,用于压缩两个生成器。 | |
| template<class T> | |
| Add< T > | console::ops::add (T v) |
| 创建加固定值变换器。 | |
| template<class T> | |
| Sub< T > | console::ops::sub (T v) |
| 创建减固定值变换器。 | |
| template<class T> | |
| Mul< T > | console::ops::mul (T v) |
| 创建乘固定值变换器。 | |
| template<class T> | |
| Div< T > | console::ops::div (T v) |
| 创建除固定值变换器。 | |
| template<class T> | |
| Mod< T > | console::ops::mod (T v) |
| 创建取模固定值变换器。 | |
| template<class T> | |
| Gt< T > | console::ops::gt (T t) |
| 创建大于谓词。 | |
| template<class T> | |
| Ge< T > | console::ops::ge (T t) |
| 创建大于等于谓词。 | |
| template<class T> | |
| Lt< T > | console::ops::lt (T t) |
| 创建小于谓词。 | |
| template<class T> | |
| Le< T > | console::ops::le (T t) |
| 创建小于等于谓词。 | |
| template<class T> | |
| Eq< T > | console::ops::eq (T v) |
| 创建等于谓词。 | |
| template<class T> | |
| Ne< T > | console::ops::ne (T v) |
| 创建不等于谓词。 | |
| template<class P, typename Q> | |
| And< P, Q > | console::ops::and_ (P p, Q q) |
| 创建逻辑与组合谓词。 | |
| template<class P, typename Q> | |
| Or< P, Q > | console::ops::or_ (P p, Q q) |
| 创建逻辑或组合谓词。 | |
| template<class P> | |
| Not< P > | console::ops::not_ (P p) |
| 创建逻辑非组合谓词。 | |
| template<class Class, typename Mem> | |
| Member< Class, Mem > | console::ops::member (Mem Class::*p) |
| 创建成员变量访问器。 | |
| template<class P, class Q> | |
| And< P, Q > | console::ops::operator&& (P p, Q q) |
| 逻辑与运算符,等价于 and_(p, q)。 | |
| template<class P, class Q> | |
| Or< P, Q > | console::ops::operator|| (P p, Q q) |
| 逻辑或运算符,等价于 or_(p, q)。 | |
| template<class P> | |
| Not< P > | console::ops::operator! (P p) |
| 逻辑非运算符,等价于 not_(p)。 | |
| template<class F, class G> | |
| Compose< F, G > | console::ops::compose (F f, G g) |
| 将两个函数组合为一个函数。 | |
| template<class F, class... Rest> | |
| auto | console::ops::compose (F f, Rest... rest) -> Compose< F, decltype(compose(rest...))> |
| 将多个函数组合为一个函数。 | |
| template<class F, class G> | |
| Compose< F, G > | console::ops::operator>> (F f, G g) |
| 函数组合运算符,将两个函数组合为一个函数。 | |
Variables | |
| static constexpr enumerate_t | console::gen::enumerate |
| static constexpr inc_t | console::ops::inc |
| static constexpr dec_t | console::ops::dec |
| static constexpr negate_t | console::ops::negate |
| static constexpr square_t | console::ops::square |
| static constexpr cube_t | console::ops::cube |
| static constexpr sqrt_t | console::ops::sqrt |
| static constexpr reciprocal_t | console::ops::reciprocal |
| static constexpr abs_t | console::ops::abs |
| static constexpr to_string_t | console::ops::to_string |
| static constexpr even_t | console::ops::even |
| static constexpr odd_t | console::ops::odd |
| static constexpr positive_t | console::ops::positive |
| static constexpr negative_t | console::ops::negative |
| static constexpr zero_t | console::ops::zero |
| static constexpr prime_t | console::ops::prime |
| static constexpr first_t | console::ops::first |
| static constexpr second_t | console::ops::second |
| static constexpr identity_t | console::ops::identity |
生成器模式头文件。
提供生成器模式的模板类实现,包含多种预定义的生成器和迭代器适配器。