Mirror reflection library - Lagoon run-time layer 0.5.13
Functions

Lagoon - Range utilities

Functions

template<typename ValueType , class... Ranges>
UnspecifiedRange< ValueType > lagoon::chain (const Ranges &...ranges)
 Chains the ranges into a single range with a common ValueType.
template<typename Interface , class... Ranges>
UnspecifiedRange< shared
< Interface > > 
lagoon::chain_mo (const Ranges &...ranges)
 Chains the ranges into a single range with a common Interface.
template<class Range , typename Predicate >
bool lagoon::contains (Range range, Predicate predicate)
 Searches a range for an element satisfying a predicate.
template<class Interface , class Range >
UnspecifiedRange< Interface > lagoon::extract (const Range &metaobjects)
 Extracts only meta-objects with a particular interface.
template<class Range , typename Predicate >
Range lagoon::find_if (Range range, Predicate predicate)
 Searches a range for an element satisfying a predicate.
UnspecifiedRange< shared
< meta_named_scoped_object > > 
lagoon::flatten (const shared< meta_scope > &scope)
 Get a range of all members of a scope including nested members.
UnspecifiedRange< shared
< meta_named_scoped_object > > 
lagoon::flatten_in_order (const shared< meta_scope > &scope)
 Get a range of all members of a scope including nested members.
template<typename State , class Range , typename BinaryOp >
State lagoon::fold (Range range, State state, BinaryOp op)
 Accumulating the results of calling a binary functor on the elements.
template<typename State , class Range , typename BinaryOp >
State & lagoon::fold_ref (Range range, State &state_ref, BinaryOp op)
 Accumulating the results of calling a binary functor on the elements.
template<typename State , class Range , typename InitialOp , typename DefaultOp , typename FinalOp >
State & lagoon::fold_ref (Range range, State &state_ref, InitialOp initial, DefaultOp op, FinalOp final)
 Accumulating the results of calling a binary functor on the elements.
template<class Range , typename Functor >
Functor lagoon::for_each (Range range, Functor func)
 Executes an unary functor on each element of a range.
template<class Range >
UnspecifiedRange lagoon::limit (Range range, size_t count)
 Limits the range to contain maximum of n elements.
template<class Range >
UnspecifiedRange lagoon::link (const std::initializer_list< Range > &ranges)
 Links the homogenous ranges into a single range.
template<class Range >
Range lagoon::offset (Range range, size_t amount)
 Offsets the beginning of the range by N elements.
template<class Range , typename Predicate >
UnspecifiedRange lagoon::only_if (Range range, Predicate predicate)
 Adapts the range to contain only elements satisfying a predicate.
template<class Range , typename SortProc >
UnspecifiedRange lagoon::sort (Range range, SortProc sort_proc)
 Sorts the elements in the range by using a strict weak ordering proc.
template<class Range >
StdRange lagoon::make_std_range (Range range)
 Adapts a Lagoon's range to have a begin() and end() functions.
template<class Range , typename Transform >
UnspecifiedRange lagoon::transform (Range range, Transform transf)
 Transforms the elements in the range by a functor.
template<class Range , typename Predicate >
UnspecifiedRange lagoon::until (Range range, Predicate predicate)
 Adapts the range to end when a predicate is satisfied.

Detailed Description

Lagoon provides an extensive set of utilities for tasks like range transformation, filtering, sorting, searching, etc. which make writing complex range manipulating algorithms easier and more straightforward.


Function Documentation

template<typename ValueType , class... Ranges>
UnspecifiedRange<ValueType> lagoon::chain ( const Ranges &...  ranges)

Chains the ranges into a single range with a common ValueType.

Returns a single range that contains a sequence of elements from the provided ranges. The elements in the individual ranges must be convertible to ValueType. The chained ranges may be of different types.

Template Parameters:
ValueTypethe common type to be used for the elements of the chained ranges
Rangesthe pack of range types to be chained
Parameters:
rangesthe pack of ranges to be chained
template<typename Interface , class... Ranges>
UnspecifiedRange<shared<Interface> > lagoon::chain_mo ( const Ranges &...  ranges)

Chains the ranges into a single range with a common Interface.

Returns a single range that contains a sequence of shared meta-objects from the provided ranges. The elements in the individual ranges must have the specified Interface.

Template Parameters:
Interfacethe common meta-object iterface to be used for the elements of the chained ranges
Rangesthe pack of range types to be chained
Parameters:
rangesthe pack of ranges to be chained
template<class Range , typename Predicate >
bool lagoon::contains ( Range  range,
Predicate  predicate 
)

Searches a range for an element satisfying a predicate.

Traverses a range checking the result of a predicate on each element. Stops at the first element satisfying the predicate and returns true. If no such elements exists in the range returns false.

Parameters:
rangethe range to be searched
predicatethe predicate to be used on each element of the range
Examples:
lagoon/example/various_02.cpp.
template<class Interface , class Range >
UnspecifiedRange<Interface> lagoon::extract ( const Range metaobjects)

Extracts only meta-objects with a particular interface.

Adapts the range so that it contains only meta-objects implementing the desired Interface. The interface of the meta-objects in the resulting range is cast to Interface.

Template Parameters:
Interfacethe desired interface
Parameters:
metaobjectsthe range or shared metaobjects to extract from
template<class Range , typename Predicate >
Range lagoon::find_if ( Range  range,
Predicate  predicate 
)

Searches a range for an element satisfying a predicate.

Traverses a range checking the result of a predicate on each element. Stops at the first element satisfying the predicate and returns the resulting range.

Parameters:
rangethe range to be searched
predicatethe predicate to be used on each element of the range
Examples:
lagoon/example/std_range_03.cpp.
UnspecifiedRange<shared<meta_named_scoped_object> > lagoon::flatten ( const shared< meta_scope > &  scope)

Get a range of all members of a scope including nested members.

This function returns a range of all members, including nested, of the scope passed as argument. No particular order of traversal is to be expected.

Parameters:
scopethe scope to be flattened
Examples:
lagoon/example/for_each_11.cpp.
UnspecifiedRange<shared<meta_named_scoped_object> > lagoon::flatten_in_order ( const shared< meta_scope > &  scope)

Get a range of all members of a scope including nested members.

This function returns a range of all members, including nested, of the scope passed as argument. The members are traversed in the same order in which they were registered and nested members of a scope are ordered right after their parent scope.

Parameters:
scopethe scope to be flattened
Examples:
lagoon/example/for_each_12.cpp.
template<typename State , class Range , typename BinaryOp >
State lagoon::fold ( Range  range,
State  state,
BinaryOp  op 
)

Accumulating the results of calling a binary functor on the elements.

Returns the result of successive application of a binary forward operation on the result of previous invocations and every element in the range.

Parameters:
rangethe range to be folded
statethe initial state used in the first invocation
opthe functor to be called on each element of the range

References Range< Element >::empty(), Range< Element >::front(), and Range< Element >::step_front().

template<typename State , class Range , typename BinaryOp >
State& lagoon::fold_ref ( Range  range,
State &  state_ref,
BinaryOp  op 
)

Accumulating the results of calling a binary functor on the elements.

Returns the result of successive application of a binary forward operation on the result of previous invocations and every element in the range.

Parameters:
rangethe range to be folded
state_refreference to the state variable gradually modified by op
opthe functor to be called on each element of the range
Examples:
lagoon/example/fold_01.cpp.

References Range< Element >::empty(), Range< Element >::front(), and Range< Element >::step_front().

template<typename State , class Range , typename InitialOp , typename DefaultOp , typename FinalOp >
State& lagoon::fold_ref ( Range  range,
State &  state_ref,
InitialOp  initial,
DefaultOp  op,
FinalOp  final 
)

Accumulating the results of calling a binary functor on the elements.

Returns the result of successive application of a binary forward operation on the result of previous invocations and every element in the range. This version uses three different binary functors; one for the first element, one for the last element and one for the remaining elements. If the range has only one element the initial functor is called.

Parameters:
rangethe range to be folded
state_refreference to the state variable gradually modified by op
initialthe functor to be called on the first element of the range
opthe functor to be called on each element of the range except the first and the last
finalthe functor to be called on the last element of the range

References Range< Element >::empty(), Range< Element >::front(), and Range< Element >::step_front().

template<class Range , typename Functor >
Functor lagoon::for_each ( Range  range,
Functor  func 
)
template<class Range >
UnspecifiedRange lagoon::limit ( Range  range,
size_t  count 
)

Limits the range to contain maximum of n elements.

Adapts the range so that it contains maximally count elements or less if the adapted range is shorter

Parameters:
rangethe range to be limited
countthe upper limit of the count of elements
Examples:
lagoon/example/for_each_05.cpp.
template<class Range >
UnspecifiedRange lagoon::link ( const std::initializer_list< Range > &  ranges)

Links the homogenous ranges into a single range.

Returns a single range that contains a sequence of elements from the provided ranges. The ranges must have the same type.

Template Parameters:
Rangethe type the of ranges to be linked
Parameters:
rangesthe list of ranges to be linked
Examples:
lagoon/example/for_each_10.cpp.
template<class Range >
StdRange lagoon::make_std_range ( Range  range)

Adapts a Lagoon's range to have a begin() and end() functions.

This function transforms the interface of a Lagoon's range adding two member functions begin() and end() returning standard const input iterators usable by standard algorithms.

Parameters:
rangethe range to be adapted
Examples:
lagoon/example/std_range_01.cpp, lagoon/example/std_range_02.cpp, lagoon/example/std_range_03.cpp, and lagoon/example/std_range_04.cpp.
template<class Range >
Range lagoon::offset ( Range  range,
size_t  amount 
) [inline]

Offsets the beginning of the range by N elements.

Adapts the range so that the front is moved by count elements or less if the adapted range is shorter. In the latter case the resulting range will be empty.

Parameters:
rangethe range to be offset
amountthe numer of elements to offset the range by
Examples:
lagoon/example/for_each_05.cpp.
template<class Range , typename Predicate >
UnspecifiedRange lagoon::only_if ( Range  range,
Predicate  predicate 
)

Adapts the range to contain only elements satisfying a predicate.

Traverses a range checking the result of a predicate on each element. Skips the elements not satisfying the predicate.

Parameters:
rangethe range to be searched
predicatethe predicate to be used to filter the range
Examples:
lagoon/example/for_each_03.cpp, lagoon/example/for_each_04.cpp, lagoon/example/for_each_06.cpp, and lagoon/example/std_range_04.cpp.
template<class Range , typename SortProc >
UnspecifiedRange lagoon::sort ( Range  range,
SortProc  sort_proc 
)

Sorts the elements in the range by using a strict weak ordering proc.

Returns a range containing the elements of the original range sorted by the binary strict weak ordering functor.

Parameters:
rangethe range to be sorted
sort_procthe functor sorting the elements
Examples:
lagoon/example/for_each_07.cpp, and lagoon/example/std_range_01.cpp.
template<class Range , typename Transform >
UnspecifiedRange lagoon::transform ( Range  range,
Transform  transf 
)

Transforms the elements in the range by a functor.

Returns a range containing the elements of the original range transformed by the unary functor.

Parameters:
rangethe range to be transformed
transfthe functor transforming the elements
Examples:
lagoon/example/for_each_06.cpp, and lagoon/example/std_range_04.cpp.
template<class Range , typename Predicate >
UnspecifiedRange lagoon::until ( Range  range,
Predicate  predicate 
)

Adapts the range to end when a predicate is satisfied.

Template Parameters:
RangeThe type of the underlying range
PredicateThe type of the terminating predicate
Parameters:
rangethe underlying range
predicatethe predicate whose satisfying stops the traversal
Examples:
lagoon/example/for_each_08.cpp.

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.