pstade

PrevUpHomeNext

Range Adaptors

adjacent_filtered
adjacent_transformed
always
applied
checked
cleared
concatenated
const_refs
constants
converted
copied_to
cycled
delimited
dropped
dropped_while
elements
elements_c
filtered
identities
indirected
outdirected
outplaced
jointed
map_keys
map_values
memoized
offset
permuted
pointed
popped
reversed
rotated
rvalues
scanned
sliced
sorted
steps
taken
taken_while
transformed
uniqued
window

A Range Adaptor delivers an altered presentation of one or more underlying ranges. Range Adaptors are lazy, meaning that their elements are only computed on demand. A Range Adaptor meets the following requirements unless otherwise specified:

Description

adjacent_filtered skips elements while a predicate applied to adjacent pairs doesn't satisfy.

Header
  • <pstade/oven/adjacent_filtered.hpp>
Model of
Notation
  • {a1,...,aN} is _rng.
  • {b1,...,bM} is a subsequence of {a1,...,aN}.
  • _prd(b1, b2), _prd(b2, b3), ..., _prd(b(M-1), bM) are true.
  • The distance from bI to bJ is minimum for all (bI, bJ).
Valid expressions

Valid expression

Semantics

_rng|adjacent_filtered(_prd)

A Forward Constant {b1,...,bM}

Preconditions
Complexity
  • At most distance(_rng) applications of the corresponding _prd.
Example
See also
Description

adjacent_transformed is considered as the adaptor version of std::adjacent_difference. It passes adjacent pairs to a function to transform repeatedly.

Header
  • <pstade/oven/adjacent_transformed.hpp>
Model of
Notation
  • {a1,...,aN} is _rng.
Valid expressions

Valid expression

Semantics

X_make_adjacent_transformed<R>

A Major Function Object type

X_make_adjacent_transformed<R>()(_rng, _fun)

{_fun(a1,a2),_fun(a2,a3),...,_fun(a(N-1),aN)} whose boost::range_reference type is R.

X_make_adjacent_transformed<>()(_rng, _cal)

{_cal(a1,a2),_cal(a2,a3),...,_cal(a(N-1),aN)}

_rng|adjacent_transformed(_cal)

X_make_adjacent_transformed<>()(_rng, _cal)

Preconditions
  • If _rng is not Forward, _value_of<_typeof(_rng)>::type is Assignable.
  • !boost::empty(_rng)
  • _fun(*_begin(_rng), *_begin(_rng)) is well-formed.
  • _fun is Assignable and Default Constructible.
  • _fun shall not modify referents.
  • _cal meets the preconditions of _fun.
Example
See also
Description

always returns a range which does not change as the base range varies.

Header
  • <pstade/oven/always.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng1|always(_rng2)

[_begin(_rng2), _end(_rng2))

Preconditions
Example
BOOST_CHECK( equals(
    std::string("labor")
        | jointed(std::string("will be"))
        | always("lost"),
    std::string("lost")
) );
Description

applied, given a function object which represents an algorithm, creates an adaptor.

Header
  • <pstade/oven/applied.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|applied(_fun1, _fun2)

[_fun1(_rng), _fun2(_rng))

_rng|applied(_fun3)

[_begin(r), _end(r)), where r = _fun3(_rng).

Preconditions
  • _typeof(_fun1(_rng)) and _typeof(_fun2(_rng)) are convertible to _iter_of<_typeof(_rng)>::type.
  • _iter_of<_typeof(fun3(_rng))>::type is convertible to _iter_of<_typeof(_rng)>::type.
  • [_fun1(_rng), _fun2(_rng)) is a Range.
  • [_begin(r), _end(_rng)), where r = _fun3(_rng), is a Range.
Complexity
  • Depends on _fun1, _fun2 and _fun3.
Example
namespace lambda = boost::lambda;
std::string src("abcdefghijk");
std::string s1("efg");
BOOST_CHECK( equals(
    std::string("efghijk"),
    src|applied(lambda::bind(search, lambda::_1, s1), end)
) );
See also
Description

checked adds the bounds checking ability to the base range.

Header
  • <pstade/oven/checked.hpp>
Model of
Valid expressions

Valid expression

Semantics

_fwdrng|checked

[_begin(_fwdrng), _end(_fwdrng))

checked_begin

An Ambi Static Function Object

checked_begin(_fwdrng)

_begin(_fwdrng|checked)

Effects
  • Throws std::out_of_range if iterators go out of _fwdrng.
Preconditions
  • The corresponding semantics is a valid expression.
Example
std::string in("012345");
std::string out("01234");

try {
    copy(in, boost::begin(out|checked));
}
catch (std::out_of_range const& ) {
    return;
}
BOOST_CHECK(false);
Description

cleared lets the base range viewed as empty.

Header
  • <pstade/oven/cleared.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|cleared

[_end(_rng), _end(_rng))

Preconditions
Example
BOOST_CHECK( boost::empty(
    std::string("labor")
        | jointed(std::string("lost"))
        | cleared
) );
See also
Description

concatenated, given a range whose values are ranges, concatenates them.

Header
  • <pstade/oven/concatenated.hpp>
Model of
Notation
  • SegmentIterator is _iter_of<_typeof(_rng)>::type.
  • LocalRange is _value_of<_typeof(_rng)>::type.
  • LocalIterator is _iter_of<LocalRange>::type.
  • {aI1,aI2,...,aIMI} is *boost::next(_begin(_rng), I).
Valid expressions

Valid expression

Semantics

_rng|concatenated

An up-to-Bidirectional {a11,a12,...,a1M1,a21,a22,...,a2M2,...,aN1,aN2,...,aMN}

Preconditions
  • _rng is Readable or Lvalue.
  • LocalRange is Range.
  • Destruction of a SegmentIterator doesn't invalidate the LocalIterator previously obtained from that iterator.
[Important] Important

The last precondition implies that SegmentIterator isn't allowed to manage the lifetime of LocalIterator referents. Hence broken_into can't meets the precondition. (xpressive_tokenized with Boost 1.35 works well.) Fortunately, memoized can turn them into Lvalue Range which meets it trivially.

Example
std::string input("This is his face");
boost::regex re("\\w+");
BOOST_CHECK( equals(
    input|tokenized(re)|concatenated,
    std::string("Thisishisface")
) );
See also
Description

const_refs converts the base range into a range of const reference, then pretends to be a range of Forward Iterator.

[Tip] Tip

Strictly speaking, an iterator obtained is not a conforming Forward Iterator.

Header
  • <pstade/oven/const_refs.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|const_refs

A Readable non-Lvalue Constant [_begin(_rng), _end(_rng)) whose boost::range_reference type is a reference type.

Preconditions
Example
See also
Description

constants converts the base range into a Constant Range.

Header
  • <pstade/oven/constants.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|constants

A Constant [_begin(_rng), _end(_rng))

Preconditions
Example
See also
Description

converted changes range referents to specified type.

Header
  • <pstade/oven/converted.hpp>
Model of
  • ...
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> boost::implicit_cast<To>(v).
Valid expressions

Valid expression

Semantics

X_make_converted<To>

A Major Function Object type

X_make_converted<To>()(_rng)

_rng|transformed(f_)

oven::make_converted<To>(_rng)

X_make_converted<To>()(_rng)

converted<To>

A Pipable Function Object type

_rng|converted<To>()

X_make_converted<To>()(_rng)

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

copied_to makes a side-effect that copies the base range to an Output Iterator.

Header
  • <pstade/oven/copied_to.hpp>
Model of
Valid expressions

Valid expression

Semantics

_fwdrng|copied_to(_outit)

[_begin(_fwdrng), _end(_fwdrng))

Effects
  • std::copy(_begin(_fwdrng), _end(_fwdrng), _outit)
Preconditions
  • std::copy(_begin(_fwdrng), _end(_fwdrng), _outit) is a valid expression.
Complexity
  • Depends on the std::copy.
Example
See also
Description

cycled creates a circular range from the base range.

Header
  • <pstade/oven/cycled.hpp>
Model of
Notation
  • {a1,...,aN} is _rng.
Valid expressions

Valid expression

Semantics

_rng|cycled(c)

A non-Swappable {a1,...,aN,a1,...,aN,...,a1,...,aN}, where a1,...,aN appears c times.

Invariants
Preconditions
  • _typeof(c) is convertible to boost::range_difference<_typeof(_rng)>::type.
  • 0 <= c
Example
BOOST_CHECK( equals(
    std::string("xyz")|cycled(3),
    std::string("xyzxyzxyz")
) );
See also
Description

delimited, given a range of range, adds a delimiter.

Header
  • <pstade/oven/delimited.hpp>
Model of
Notation
  • join is regular(boost::lambda::bind(make_jointed, _rng2, boost::lambda::_1)).
Valid expressions

Valid expression

Semantics

_rng1|delimited(_rng2)

_rng1|transformed(join)|concatenated

Preconditions
  • make_jointed(_rng2, *_begin(_rng1)) is well-formed.
  • _rng1|transformed(join)|concatenated is a valid expression.
[Tip] Tip

delimited prepends the delimiter. dropped is useful to remove it.

Example
BOOST_CHECK( equals(
    std::string("abcde")|transformed(single)|
        delimited("--"|as_literal)|dropped(2),
    std::string("a--b--c--d--e")
) );
See also
Description

dropped returns the suffix of the base range after the first n elements.

Header
  • <pstade/oven/dropped.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|dropped(n)

[boost::next(_begin(_rng), std::min(n, distance(_rng))), _end(_rng))

Preconditions
  • _typeof(n) is convertible to boost::range_difference<typeof(_rng)>::type.
  • 0 <= n
Complexity
Example
BOOST_CHECK( equals(
    std::string("hello, dropped!")|dropped(7),
    std::string("dropped!")
) );
See also
Description

dropped_while drops elements from the base range while a predicate satisfies.

Header
  • <pstade/oven/dropped_while.hpp>
Model of
Notation
  • not_ is an imaginary function to nagate a predicate.
Valid expressions

Valid expression

Semantics

_rng|dropped_while(_prd)

[std::find_if(_begin(_rng), _end(_rng), not_(_prd)), _end(_rng))

Preconditions
Complexity
  • At most distance(_rng) applications of the corresponding _prd.
Example
std::string src("11111234516313!");

BOOST_CHECK( equals(
    src|dropped_while(boost::lambda::_1 == '1'),
    std::string("234516313!")
) );
See also
Description

elements is considered as a generalization of map_keys and map_values.

Header
  • <pstade/oven/elements.hpp>
Model of
Notation
  • Tup is _value_of<_typeof(_rng)>::type.
  • to_Nth is an imaginary function object to get the Nth element of Boost.Fusion Sequence.
Valid expressions

Valid expression

Semantics

X_make_elements<N, Ref = boost::use_default>

A Major Function Object type

X_make_elements<N, Ref = boost::use_default>()(_rng)

_rng|transformed(to_Nth)

oven::make_elements<N>(_rng)

X_make_elements<N>()(_rng)

elements<N>

A Pipable Function Object type

_rng|elements<N>()

X_make_elements<N>()(_rng)

Preconditions
  • _rng is Readable or Lvalue.
  • Tup is Fusion Forward Sequence.
  • N is a MPL Integral Constant.
  • Ref specifies boost::range_reference type of an adapted range. If Ref is boost::use_default, Ref is determined by the following:
    • If boost::range_reference<_typeof(_rng)>::type is a reference type, it is a reference type.
    • Otherwise boost::fusion::result_of::value_of is used to specify it.
Example
See also
Description
Header
  • <pstade/oven/elements.hpp>
Model of
Valid expressions

Valid expression

Semantics

X_make_elements_c<n, Ref = boost::use_default>

X_make_elements<boost::mpl::int_<n>, Ref>

oven::make_elements_c<n>(_rng)

oven::make_elements< boost::mpl::int_<n> >(_rng)

elements_c<n>

elements< boost::mpl::int_<n> >

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

filtered returns a filter_iterator range.

Header
  • <pstade/oven/filtered.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|filtered(_prd)

[T(_prd, _begin(_rng), _end(_rng)), T(_prd, boos::end(_rng), _end(_rng)))

Preconditions
  • T is boost::filter_iterator<_typeof(_prd), _typeof(_begin(_rng))> such that T(_prd, _begin(_rng), _end(_rng)) is a valid expression.
  • _prd is Assignable and Default Constructible.
  • _prd shall not modify referents.
Complexity
  • At most distance(_rng) applications of the corresponding _prd.
Example
See also
Description

identities returns the base range as is, but can change the traversal category.

Header
  • <pstade/oven/identities.hpp>
Model of
Notation
  • traversal is an imaginary metafunction which returns a traversal tag type known as boost::xxx_traversal_tag.
Valid expressions

Valid expression

Semantics

_rng|identities(t)

[_begin(_rng), _end(_rng)) whose traversal type is _typeof(t).

_rng|identities

_rng|identities(traversal<_typeof(_rng)>::type())

Preconditions
  • There is a xxx such that _typeof(t) is boost::xxx_traversal_tag.
  • traversal<_typeof(_rng)>::type is convertible to _typeof(t).
Example
See also
Description

indirected adapts the base range by applying an extra dereference inside of operator*().

Header
  • <pstade/oven/indirected.hpp>
Model of
Valid expressions

Valid expression

Semantics

X_make_indirected<X1,...,XN>

A Major Function Object type

X_make_indirected<X1,...,XN>()(_rng)

[T(_begin(_rng), T(_end(_rng)))

_rng|indirected

X_make_indirected<>()(_rng)

Preconditions
  • T is boost::indirect_iterator<_iter_of<_typeof(_rng)>::type, X1,...,XN> such that T(_begin(_rng)) is a valid expression.
Example
int src[]    = { 1,2,0,4,5 };
int answer[] = { 1,2,3,4,5 };
int *ptrs[]  = {&src[0],&src[1],&src[2],&src[3],&src[4]};

BOOST_FOREACH (int& i, ptrs|indirected) {
    if (i == 0)
        i = 3;
}

BOOST_CHECK( equals(src, answer) );
See also
Description

outdirected returns a range whose values are iterators of the base range.

Header
  • <pstade/oven/outdirected.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|outdirected

counting(_begin(_rng), _end(_rng))

Preconditions
Example
std::string const str("gefadcb");
std::string const answer("abcdefg");

std::vector<std::string::const_iterator> iters;
copy(str|outdirected, std::back_inserter(iters));
sort( iters, boost::make_indirect_fun(::less_than()) );

BOOST_CHECK( equals(iters|indirected, answer) );
See also
Description

outplaced provides a Random Access view through the base range iterators.

Header
  • <pstade/oven/outplaced.hpp>
Model of
Notation
  • iK = boost::next(boost::begin(_fwdrng), K-1)
  • N is distance(_fwdrng).
Valid expressions

Valid expression

Semantics

_fwdrng|outplaced

A Random Access Writable Lvalue {i1,...,iN}

Preconditions
Complexity
  • O(N)
Example
std::list<int> lst = initial_values(6,1,3,2,5,4);
sort(lst|outplaced|indirected);
BOOST_CHECK( equals(lst, initial_values(1,2,3,4,5,6)) );
See also
Description

jointed returns a range which is jointed with its argument.

Header
  • <pstade/oven/jointed.hpp>
Model of
Notation
  • {a1,...,aN} is _rng1.
  • {b1,...,bM} is _rng2.
  • cK = a1 for all K such that 1 <= K && K <= N.
  • cK = boost::implicit_cast<boost::range_reference<_typeof(_rng1)>::type>(b(K-N)) for all K such that N+1 <= K && K <= N+M.
Valid expressions

Valid expression

Semantics

_rng1|jointed(_rng2)

{c1,...,c(N+M)}

Invariants
  • The traversal category of {c1,...,c(N+M)} is minimum of _rng1 and _rng2.
  • {c1,...,c(N+M)} is Swappable if and only if both _rng1 and _rng2 is Readable and Writable.
Preconditions
  • _rng1 is Readable or Lvalue.
  • boost::range_reference<_typeof(_rng2)>::type is convertible to boost::range_reference<_typeof(_rng1)>::type without binding reference to rvalue.
Example
std::string str0("every range");
std::vector<char> str1 = std::string(" is")|copied;
std::list<char> str2 = std::string(" string!?")|copied;

BOOST_CHECK( equals(
    str0|jointed(str1)|jointed(str2),
    std::string("every range is string!?")
) );
See also
Description

map_keys returns a range whose values are the keys of the base associative container.

Header
  • <pstade/oven/map_keys.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|map_keys

_rng|elements_c<0>()

Preconditions
  • _rng|elements_c<0>() is a valid expression.
Example
std::map<int, std::string> m;
m[12] = "hello";
m[4]  = "map";
m[99] = "keys";

BOOST_FOREACH (int k, m|map_keys) {
    BOOST_CHECK( k != 12 || m[k] == "hello" );
    BOOST_CHECK( k != 4  || m[k] == "map" );
    BOOST_CHECK( k != 99 || m[k] == "keys" );
}
See also
Description

map_values returns a range whose values are the mapped values of the base associative container.

Header
  • <pstade/oven/map_values.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng1|map_values

_rng|elements_c<1>()

Preconditions
  • _rng|elements_c<1>() is a valid expression.
Example
std::map<int, std::string> m;
m[12] = "hello";
m[4]  = "map";
m[99] = "keys";

BOOST_FOREACH (std::string& v, m|map_values) {
    if (v == "keys")
        v = "values";
}

BOOST_CHECK( m[12] == "hello" );
BOOST_CHECK( m[4]  == "map" );
BOOST_CHECK( m[99] == "values" );
See also
Description

memoized returns a range whose values are cached for speed, preparing for repeated dereferences.

Header
  • <pstade/oven/memoized.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|memoized

A Forward Lvalue Constant [_begin(_rng), _end(_rng))

_rng|memoized(t)

_rng|memoized

[Note] Note

memoized can return a Forward Range even if the base range is Single Pass.

Preconditions
  • _rng is Readable.
  • _value_of<_typeof(_rng)>::type is Assignable.
  • If _rng is a recursive range, memo_table object t must be passed.
Invariants
Example
std::stringstream ss;
ss << "hello, memoized!";

::very_complicated_algorithm(
    oven::stream_read<char>(ss)
        | memoized
        | directed
        | indirected
        | sorted
        | memoized
);
See also
Description
Header
  • <pstade/oven/offset.hpp>
Model of
Valid expressions

Valid expression

Semantics

_fwdrng|offset(n, m)

[boost::next(_begin(_fwdrng), n), boost::next(_end(_fwdrng), m))

Preconditions
  • boost::next(_begin(_fwdrng), n) is a valid expression.
  • boost::next(_end(_fwdrng), m) is a valid expression.
  • n <= distance(_fwdrng) + m
Complexity
Example
See also
Description

permuted provides a permuted view of a given range. That is, the view includes every element of the given range but in a potentially different order.

Header
  • <pstade/oven/permuted.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng1|permuted(_rng2)

[T(_begin(_rng1), _begin(_rng2)), T(_begin(_rng1), _end(_rng2))))

Preconditions
  • T is boost::permutation_iterator<_iter_of<_typeof(_rng1)>::type, _iter_of<_typeof(_rng2)>::type> such that T(_begin(_rng1), _begin(_rng2)) is a valid expression.
Example
See also
Description

pointed, by returning a pointer range, provides an interface to have a conversation with legacy APIs. Also, you can expect STL to choose optimized implementation by passing raw pointers.

Header
  • <pstade/oven/pointed.hpp>
Model of
Valid expressions

Valid expression

Semantics

r|pointed

[p, p + distance(r)), where p = &*_begin(r).

q|pointed

[(P)0, (P)0), where P is boost::range_pointer<_typeof(q)>::type.

Preconditions
Example
std::string const src("hello, pointed");
std::vector<char> vec;
vec.resize(distance(src) + 1);
std::strcpy(boost::begin(vec|pointed), src.c_str());
BOOST_CHECK(( equals(vec|as_c_str, src) ));
See also
Description

popped returns a range without the last element.

Header
  • <pstade/oven/popped.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|popped

[_begin(_rng), boost::next(_begin(_rng), distance(_rng) - 1))

Preconditions
  • !boost::empty(_rng)
  • If _rng is not Forward, _value_of<_typeof(_rng)>::type is Assignable.
Example
See also
Description

A range returned from reversed iterates in the opposite direction.

Header
  • <pstade/oven/reversed.hpp>
Model of
Valid expressions

Valid expression

Semantics

_bidrng|reversed

[T(boost:end(_bidrng)), T(_begin(_bidrng)))

Preconditions
  • T is boost::reverse_iterator<boost::_iter_of<_typeof(_bidrng)>::type> such that T(_begin(_bidrng)) is a valid expression.
Example
See also
Description

rotated provides a rotated view of a given range.

Header
  • <pstade/oven/rotated.hpp>
Model of
Notation
  • mid is _fun(_fwdrng).
Valid expressions

Valid expression

Semantics

_fwdrng|rotated(_fun)

[mid, _end(_fwdrng))|jointed([mid, _fun(_fwdrng))

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

rvalues returns a range whose boost::range_reference type is the same as boost::range_value type.

Header
  • <pstade/oven/rvalues.hpp>
Model of
Notation
  • to_v is an imaginary function object to convert the argument to _value_of<_typeof(_rng>)>::type.
Valid expressions

Valid expression

Semantics

_rng|rvalues

_rng|transformed(to_v)

Preconditions
Example
See also
Description

scanned is similar to std::accumulate, but returns a range of successive reduced values from the base range.

Header
  • <pstade/oven/scanned.hpp>
Model of
Notation
  • {a1,a2,...,aN} is _rng.
  • {b1,b2,...,bM} is _rng1.
  • S1 is _value_of<_typeof(_rng1)>::type.
Valid expressions

Valid expression

Semantics

_rng|scanned(s, _fun)

An up-to-Forward Readable non-Lvalue Constant {s,_fun(s, a1),_fun(_fun(s, a1), a2),_fun(_fun(_fun(s, a1), a2), a3),...,aN)}

_rng1|scanned(_fun1)

An up-to-Forward Readable non-Lvalue Constant {b1,_fun1(b1, b2),_fun1(_fun(b1, b2), b3),_fun1(_fun1(_fun1(b1, b2), b3), b4),...,bM)}

[Note] Note

s is copied, meaning that it is not referenced from Oven later.

Preconditions
Example
int const src[] = { 1,2,3,4,5 };
std::string null;

BOOST_FOREACH (std::string str, src|scanned(null, &::stringize)) {
    std::cout << "\"" << str << "\" ";
}
// outputs: "" "1" "12" "123" "1234" "12345"
See also
Description

sliced provides a column view of the base range.

[Important] Important

This name comes from std::slice and different from Range Library Proposal, which is the role of offset or window.

Header
  • <pstade/oven/sliced.hpp>
Model of
Notation
  • f is _begin(_rndrng).
Valid expressions

Valid expression

Semantics

_rndrng|sliced(s, t)

{*(f+s+t*0),*(f+s+t*1),*(f+s+t*2),...,*(f+s+t*(n-1))}

Preconditions
  • _typeof(s) and _typeof(t) are convertible to boost::range_difference<typeof(_rndrng)>::type.
  • n is distance(_rndrng) / t such that n == 0 || n % t == 0.
  • 0 <= s && s < t
Example
int const answer[] = { 2,6,10,14 };
BOOST_CHECK( equals(answer,
    counting(0, 16)|sliced(2, 4)
) );
See also
Description

sorted provides a sorted view of the base range.

[Caution] Caution

Though sorted can accept Forward (possibly Constant) Range, it may be considered expensive in some applications.

Header
  • <pstade/oven/sorted.hpp>
Model of
Notation
  • less is boost::lambda::_1 < boost::lambda::_2.
Valid expressions

Valid expression

Semantics

_fwdrng|sorted(_prd)

A Range which behaves as it were made by sort(_fwdrng, _prd).

_fwdrng|sorted

_fwdrng|sorted(less)

Preconditions
  • _prd shall not modify referents.
Complexity
  • O(N) + O(NlogN), where N is distance(_fwdrng).
Example
std::stringstream in;
in << "cefabd";
BOOST_CHECK( equals(oven::stream_read<char>(in)|memoized|sorted, std::string("abcdef")) );
See also
Description

steps, though it can't return Bidirectional Range, relaxes the preconditions of sliced and accepts a Single Pass Range.

Header
  • <pstade/oven/steps.hpp>
Model of
Notation
  • iK = boost::next(boost::begin(_rng), w*K-1))
  • M is the largest number such that iM < _end(_rng).
Valid expressions

Valid expression

Semantics

_rng|steps(w)

An up-to-Forward {*i1,*i1,*i2,*i3,...,*iM}

Preconditions
  • _typeof(w) is convertible to boost::range_difference<_typeof(_rng)>::type.
  • 1 <= w
Example
int const answer[] = { 0, 40, 80 };
BOOST_CHECK( equals(
    counting(0, 100)|steps(10)|steps(4),
    answer
) );
See also
Description

taken, applied to the base range, returns the prefix of the range of length n.

Header
  • <pstade/oven/taken.hpp>
Model of
Valid expressions

Valid expression

Semantics

_rng|taken(n)

An up-to-Forward [_begin(_rng), boost::next(_begin(_rng), std::min(n, distance(_rng))))

[Note] Note

taken can't return a Bidirectional-or-more Range; for the laziness, meaning that taken returns in constant time. If you don't want to reduce the traversal category, use window or offset, which doesn't return in constant-time unless the base range is Random Access.

Preconditions
  • _typeof(n) is convertible to range_difference<_typeof(_rng)>::type.
Example
See also
Description

taken_while, applied to a predicate and the base range, returns the longest prefix (possibly empty) of the range of elements that satisfy the predicate.

Header
  • <pstade/oven/taken_while.hpp>
Model of
Notation
  • not_ is an imaginary function to nagate a predicate.
Valid expressions

Valid expression

Semantics

_rng|taken_while(_prd)

An up-to-Forward [_begin(_rng), std::find_if(_begin(_rng), _end(_rng), not_(_prd)))

Preconditions
Example
See also
Description

transformed returns a transform_iterator range.

Header
  • <pstade/oven/transformed.hpp>
Model of
Valid expressions

Valid expression

Semantics

X_make_transformed<R = boost::use_default>

A Major Function Object type

X_make_transformed<R = boost::use_default>()(_rng, _fun)

[T(_begin(_rng), _fun), T(_end(_rng), _fun))

_rng|transformed(_cal)

X_make_transformed<>()(_rng, _cal)

Preconditions
  • R specifies boost::range_reference type of an adapted range.
  • T is boost::transform_iterator<_typeof(_fun), _typeof(_begin(_rng)), R> such that T(_begin(_rng), _fun) is a valid expression.
  • If R is boost::use_default, _fun must be a Polymorphic Function Object. Then R is regarded as boost::result_of<_typeof(_fun)(boost::range_reference<_typeof(_rng)>::type)>::type.
  • _fun is Assignable and Default Constructible.
  • _fun and _cal shall not modify referents.
Example
See also
Description
Header
  • <pstade/oven/uniqued.hpp>
Model of
Notation
  • not_ is an imaginary function to nagate a predicate.
  • eq is regular(boost::lambda::_1 == boost::lambda::_2).
Valid expressions

Valid expression

Semantics

_rng|uniqued(_prd)

_rng|adjacent_filtered(not_(_prd))

_rng|uniqued

_rng|uniqued(eq)

Preconditions
  • _rng|adjacent_filtered(not_(_prd)) is a valid expression.
Complexity
  • At most distance(_rng) applications of the corresponding _prd.
Example
See also
Description
Header
  • <pstade/oven/window.hpp>
Model of
Valid expressions

Valid expression

Semantics

_fwdrng|window(n, m)

[boost::next(_begin(_fwdrng), n), boost::next(_begin(_fwdrng), m))

Preconditions
  • boost::next(_begin(_fwdrng), n) is a valid expression.
  • boost::next(_begin(_fwdrng), m) is a valid expression.
  • n <= m
Complexity
Example
See also
Copyright 2005 -2007 Shunsuke Sogame

PrevUpHomeNext