rangeextension

Next

Chapter 1. Range Extension 0.1

Akira Takahashi

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

Reference
Range Adaptors
adjacent_zipped
dropped
dropped_while
elements
elements_key
memoized
outdirected
taken
taken_while
Regular Extension
filtered
transformed
Algorithm Extension
all_of
any_of
fused_for_each
none_of
Range Access
at
value_at
back
value_back
front
value_front
Range Utilities
as_container
directory_range
iteration
recursive_directory_range
regular
single
split_at
Design Rationale
Regular Operator
Acknowledments

This library is enhanced version of Boost Range Library.
It has powerful Range adaptors and utilities for Range programming.
For example, using this library, we can write quick sort as the following:

typedef
    any_range<int, forward_traversal_tag, int&, std::ptrdiff_t>
range;

range quick_sort(range rng)
{
    if (!rng)
        return rng;
    else {
        int& x = rng | front;
        range xs = rng | dropped(1);

        return
            join(
                join(
                    quick_sort(xs |+ filtered(_1 < x)),
                    single(x)
                ),
                quick_sort(xs |+ filtered(_1 >= x))
            );
    }
}

std::vector<int> v = boost::assign::list_of(3)(2)(5)(4)(6)(1);
std::cout << quick_sort(range(v)) << std::endl;

Last revised: January 20, 2013 at 11:38:07 GMT


Next