RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
|
#include <functional>
#include <iterator>
#include <algorithm>
#include <numeric>
#include <list>
#include <map>
#include <set>
#include <memory>
#include <utility>
#include <type_traits>
#include <vector>
#include <cstddef>
#include "util.hpp"
#include "linq_cursor.hpp"
#include "linq_iterators.hpp"
#include "linq_select.hpp"
#include "linq_take.hpp"
#include "linq_skip.hpp"
#include "linq_groupby.hpp"
#include "linq_where.hpp"
#include "linq_last.hpp"
#include "linq_selectmany.hpp"
Go to the source code of this file.
Classes | |
class | cpplinq::linq_driver< Collection > |
Namespaces | |
cpplinq | |
Macros | |
#define | LINQ_USE_RTTI 1 |
Functions | |
template<class TContainer > | |
linq_driver< iter_cursor< typename util::container_traits< TContainer >::iterator > > | cpplinq::from (TContainer &c) |
template<class T > | |
const linq_driver< T > & | cpplinq::from (const linq_driver< T > &c) |
template<class Iter > | |
linq_driver< iter_cursor< Iter > > | cpplinq::from (Iter start, Iter finish) |
template<class TContainer > | |
linq_driver< TContainer > | cpplinq::from_value (const TContainer &c) |
#define LINQ_USE_RTTI 1 |
Defines a number of range-based composable operators for enumerating and modifying collections
The general design philosophy is to (1) emulate the composable query patterns introduced in C# Linq (2) preserve iterator category and writability where possible For instance, like C# Linq we have a select operator to project one sequence into a new one. Unlike Linq, invoking Select on a random access sequence will yield you a random access sequence.
The general workflow begins with 'from()' which normally only takes a reference the the collection in question. However, from that point on, all operators function by value, so that the range can store any necessary state, rather than duplicating it onto iterator pairs.
In subsequent documentation, "powers" lists which powers that the operator attempts to preserve if available on on the input sequence. Some iterator powers may be skipped - in such a case, round down to the next supported power (e.g. if 'fwd' and 'rnd', an input of 'bidi' will round down to a 'fwd' result).
Construct a new query, from an lvalue reference to a collection. Does not copy the collection
Construct a new query, from an iterator pair.
For each element x
in the input sequences, computes map(x)
for the result sequence.
Each element x
in the input appears in the output if pred(x)
is true.
The expression pred(x)
is evaluated only when moving iterators (op++, op–). Dereferencing (op*) does not invoke the predicate.
Result: Query of groups. Each group has a 'key' field, and is a query of elements from the input. Powers: forward
(No argument) Returns true if sequence is non-empty. Equivalent to query.begin()!=query.end()
(One argument) Returns true if the sequence contains any elements for which pred(element)
is true. Equivalent to query.where(pred).any()
.
Returns true if pred
holds for all elements in the sequence. Equivalent to !query.any(std::not1(pred))
Returns a sequence that contains up to n
items from the original sequence.
Returns a sequence that skips the first n
items from the original sequence, or an empty sequence if fewer than n
were available on input.
Note: begin() takes O(n) time when input iteration power is weaker than random access.
TODO: should use inner container's iterator distance type instead.
(Zero-argument) Returns the number of elements in the range. Equivalent to std::distance(query.begin(), query.end())
(One-argument) Returns the number of elements for whicht pred(element)
is true. Equivalent to query.where(pred).count()