Java style fuent class. More...
#include <fluent.hpp>
Public Member Functions | |
| Fluent ()=delete | |
| Fluent (C< T > &container) | |
| Fluent (C< T > &&container) | |
| Fluent (const Fluent &other)=default | |
| Fluent (Fluent &&other) noexcept=default | |
| ~Fluent ()=default | |
| Fluent & | filter (std::function< bool(const T &)> predicate) |
| Fluent & | skip (uint64_t skip) |
| Fluent & | limit (uint64_t limit) |
| Fluent & | concat (Fluent< T, C > &other) noexcept |
| bool | allMatch (std::function< bool(const T &)> predicate) |
| bool | anyMatch (std::function< bool(const T &)> predicate) |
| bool | noneMatch (std::function< bool(const T &)> predicate) |
| void | forEach (std::function< void(T &)> action) |
| template<typename U> | |
| Fluent< U, std::vector > | map (std::function< U(const T &)> mapper) |
| template<typename D> | |
| void | collect (D &container, std::function< void(D &, const T &)> collector) |
| template<typename D> | |
| D | collect (std::function< void(D &, const T &)> collector) |
| template<typename D, typename R> | |
| void | collect (D &container, R(D::*collector)(const T &)) |
| template<typename D, typename R> | |
| D | collect (R(D::*collector)(const T &)) |
Java style fuent class.
Fluent aims to lazily apply treatment on container.
Every operation is stored until final operation is call. They are applied in their insertion order.
skip and limit count elements across concatenated fluents (concat) ; only the operations of the first fluent are applied.
Final operations can be called several times: skip and limit counters are reset on each call.
A fluent built on a container reference does not own it: the container has to outlive the fluent. A fluent built on a temporary container (or returned by map) owns its values.
|
delete |
Forbids Fluent constructor
| anch::Fluent< T, C >::Fluent | ( | C< T > & | container | ) |
Build fluent from container. The container has to outlive the fluent.
| container | the container |
| anch::Fluent< T, C >::Fluent | ( | C< T > && | container | ) |
Build fluent from temporary container. The fluent owns the values.
| container | the container |
|
default |
|
defaultnoexcept |
|
default |
Fluent destructor
| bool anch::Fluent< T, C >::allMatch | ( | std::function< bool(const T &)> | predicate | ) |
Check if every items in fluent match a predicate
| predicate | the function to use to check items |
| bool anch::Fluent< T, C >::anyMatch | ( | std::function< bool(const T &)> | predicate | ) |
Check if there is at least one item in fluent that matches a predicate
| predicate | the function to use to check items |
| void anch::Fluent< T, C >::collect | ( | D & | container, |
| R(D::* | collector )(const T &) ) |
Collect fluent items in container
| container | the container to fill |
| collector | the collector function |
| void anch::Fluent< T, C >::collect | ( | D & | container, |
| std::function< void(D &, const T &)> | collector ) |
Collect fluent items in container
| container | the container to fill |
| collector | the collector function |
| D anch::Fluent< T, C >::collect | ( | R(D::* | collector )(const T &) | ) |
Collect fluent items in container
| collector | the collector function |
| D anch::Fluent< T, C >::collect | ( | std::function< void(D &, const T &)> | collector | ) |
Collect fluent items in container
| collector | the collector function |
|
noexcept |
Fluent lazy 'concatenation'.
The concatenated fluent has to outlive this one.
| other | the fluent to concatenate |
| Fluent & anch::Fluent< T, C >::filter | ( | std::function< bool(const T &)> | predicate | ) |
Add filter function
| predicate | the filter function |
| void anch::Fluent< T, C >::forEach | ( | std::function< void(T &)> | action | ) |
Apply treatment for each item in fluent.
Items are passed by reference: the action can modify them.
| action | the function to execute on each item |
| Fluent & anch::Fluent< T, C >::limit | ( | uint64_t | limit | ) |
Limit the number of elements
| limit | the number maximum of elements to treat |
| Fluent< U, std::vector > anch::Fluent< T, C >::map | ( | std::function< U(const T &)> | mapper | ) |
Create a new fluent transforming current fluent type into another.
| mapper | the mapping function |
| bool anch::Fluent< T, C >::noneMatch | ( | std::function< bool(const T &)> | predicate | ) |
Check if there is no item in fluent that matches a predicate
| predicate | the function to use to check items |
| Fluent & anch::Fluent< T, C >::skip | ( | uint64_t | skip | ) |
Skip elements
| skip | the elements to skip |