Honeycomb  0.1
Component-Model Framework
Namespaces | Classes | Macros | Functions
Range Util

Methods that create and operate on ranges. More...

Collaboration diagram for Range Util:

Namespaces

 honey::mt
 Meta-programming and compile-time util.
 

Classes

class  honey::mt::isRange< T >
 Check if type is a range or a reference to one. A range is a type where std::begin(range) is a valid call. More...
 
struct  honey::mt::iterOf< Range >
 Get range iterator begin type. More...
 
struct  honey::mt::iter_endOf< Range >
 Get range iterator end type. More...
 
struct  honey::mt::elemOf< Range >
 Get range element type. More...
 
class  honey::Range_< T1_, T2_ >
 Iterator range. See range(Iter1&&, Iter2&&) to create. More...
 
class  honey::IntIter< T >
 Incremental integer iterator (step size = 1). See range(int, int) to create. More...
 
class  honey::IntStepIter< T >
 Integer iterator with step size. See range(int, int, int) to create. More...
 
class  honey::RealIter< T >
 Real number iterator. See range(Real, Real, Real) to create. More...
 
class  honey::TupleIter< Iter, I, IterCategory >
 Wrapper around an iterator with tuple value type. When dereferenced returns I'th element. More...
 
class  honey::TupleIter< Iter, I, std::forward_iterator_tag >
 
class  honey::TupleIter< Iter, I, std::bidirectional_iterator_tag >
 
class  honey::RingIter< Range, Iter >
 Ring iterator. See ringRange() to create. More...
 

Macros

#define RANGE_ARG_MAX   3
 Max args for range related variable argument functions. More...
 

Functions

template<class Iter >
auto honey::seqToIter (Iter &&seq) -> typename std::enable_if< mt::isIterator< Iter >::value, Iter && >::type
 Convert a sequence to a forward iterator. Overload for iterator type. Returns the iterator itself. More...
 
template<class Range >
auto honey::seqToIter (Range &&seq) -> typename std::enable_if< mt::isRange< Range >::value, mt_iterOf(seq)>::type
 Convert a sequence to a forward iterator. Overload for range type. Returns the range's begin iterator. More...
 
template<class Iter1 , class Iter2 >
std::enable_if< mt::isIterator< Iter1 >::value, Range_< Iter1, Iter2 > >::type honey::range (Iter1 &&first, Iter2 &&last)
 Range from iterators [first, last) More...
 
template<class T1 , class T2 >
Range_< T1, T2 > honey::range (pair< T1, T2 > &p)
 Range from iterator pair [first, second) More...
 
template<class T1 , class T2 >
Range_< T1, T2 > honey::range (const pair< T1, T2 > &p)
 
template<class T1 , class T2 >
Range_< T1, T2 > honey::range (tuple< T1, T2 > &t)
 Range from iterator tuple [0, 1) More...
 
template<class T1 , class T2 >
Range_< T1, T2 > honey::range (const tuple< T1, T2 > &t)
 
template<class Range >
auto honey::reversed (Range &&range) -> Range_< std::reverse_iterator< mt_iterOf(range)>, std::reverse_iterator< mt_iter_endOf(range)>>
 Reverse a range. Begin/End iterators must be bidirectional. More...
 
OutSeq && honey::map (Range &&, Seqs &&..., OutSeq &&, Func &&)
 Transform a series of sequences into an output. More...
 
Accum honey::reduce (Range &&, Seqs &&..., Accum &&initVal, Func &&)
 Accumulate a series of sequences into an output. More...
 
Iter honey::find (Range &&, Seqs &&..., Func &&pred)
 Find an element in a series of sequences. More...
 
Range_< FilterIter, FilterIter > honey::filter (Range &&, Seqs &&..., Func &&pred)
 Filter a range by ignoring undesired elements. More...
 
template<class Range >
szt honey::countOf (Range &&range)
 Count number of elements in range. More...
 
template<class Range >
void honey::deleteRange (Range &&range)
 Delete all elements in range. More...
 
template<class Range , class Alloc >
void honey::deleteRange (Range &&range, Alloc &&a)
 Delete all elements in range using allocator. More...
 
template<class Int , class Int2 , class Int_ = typename std::common_type<Int,Int2>::type>
std::enable_if< std::is_integral< Int_ >::value, Range_< IntIter< Int_ >, IntIter< Int_ > > >::type honey::range (Int begin, Int2 end)
 Create a range that increments through the integral range [begin,end) More...
 
template<class Int >
std::enable_if< std::is_integral< Int >::value, Range_< IntIter< Int >, IntIter< Int > > >::type honey::range (Int end)
 Create a range that increments through the integral range [0,end) More...
 
template<class Int , class Int2 , class Int3 , class Int_ = typename std::common_type<Int,Int2,Int3>::type>
std::enable_if< std::is_integral< Int_ >::value, Range_< IntStepIter< Int_ >, IntStepIter< Int_ > > >::type honey::range (Int begin, Int2 end, Int3 step)
 Create a range that steps through the integral range [begin,end) More...
 
template<class Real , class Real2 , class Real3 , class Real_ = typename std::common_type<Real,Real2,Real3>::type>
std::enable_if< std::is_floating_point< Real_ >::value, Range_< RealIter< Real_ >, RealIter< Real_ > > >::type honey::range (Real begin, Real2 end, Real3 step=1)
 Create a range that steps through the real number range [begin,end) More...
 
template<class Range , class Iter >
auto honey::ringRange (Range &&range, const Iter &cur) -> Range_< RingIter< Range, Iter >, RingIter< Range, Iter >>
 Create an iterator adapter range that does one full cyclic loop starting at cur through the range. More...
 

Detailed Description

Methods that create and operate on ranges.

Macro Definition Documentation

#define RANGE_ARG_MAX   3

Max args for range related variable argument functions.

Function Documentation

template<class Range >
szt honey::countOf ( Range &&  range)

Count number of elements in range.

template<class Range >
void honey::deleteRange ( Range &&  range)

Delete all elements in range.

template<class Range , class Alloc >
void honey::deleteRange ( Range &&  range,
Alloc &&  a 
)

Delete all elements in range using allocator.

Range_<FilterIter, FilterIter> honey::filter ( Range &&  ,
Seqs &&  ...,
Func &&  pred 
)

Filter a range by ignoring undesired elements.

Behaviour is the same as repeatedly calling find() passing in the returned iterator until the end is reached.

Iter honey::find ( Range &&  ,
Seqs &&  ...,
Func &&  pred 
)

Find an element in a series of sequences.

Call predicate function for each element in the range and any sequences, pred(rangeElem, seq1Elem, seq2Elem...), returning an iterator to the first element for which the predicate returns true. Returns range end if the predicate is false for all elements.

OutSeq&& honey::map ( Range &&  ,
Seqs &&  ...,
OutSeq &&  ,
Func &&   
)

Transform a series of sequences into an output.

Call function for each element in the range and any sequences, f(rangeElem, seq1Elem, seq2Elem...), storing the results in the output sequence. Returns the output sequence.

map() can be specialized through the function: priv::map_impl<Range, OutSeq, Seqs...>::func(...)

template<class Iter1 , class Iter2 >
std::enable_if<mt::isIterator<Iter1>::value, Range_<Iter1,Iter2> >::type honey::range ( Iter1 &&  first,
Iter2 &&  last 
)

Range from iterators [first, last)

template<class T1 , class T2 >
Range_<T1,T2> honey::range ( pair< T1, T2 > &  p)

Range from iterator pair [first, second)

template<class T1 , class T2 >
Range_<T1,T2> honey::range ( const pair< T1, T2 > &  p)
template<class T1 , class T2 >
Range_<T1,T2> honey::range ( tuple< T1, T2 > &  t)

Range from iterator tuple [0, 1)

template<class T1 , class T2 >
Range_<T1,T2> honey::range ( const tuple< T1, T2 > &  t)
template<class Int , class Int2 , class Int_ = typename std::common_type<Int,Int2>::type>
std::enable_if<std::is_integral<Int_>::value, Range_<IntIter<Int_>, IntIter<Int_> > >::type honey::range ( Int  begin,
Int2  end 
)

Create a range that increments through the integral range [begin,end)

template<class Int >
std::enable_if<std::is_integral<Int>::value, Range_<IntIter<Int>, IntIter<Int> > >::type honey::range ( Int  end)

Create a range that increments through the integral range [0,end)

template<class Int , class Int2 , class Int3 , class Int_ = typename std::common_type<Int,Int2,Int3>::type>
std::enable_if<std::is_integral<Int_>::value, Range_<IntStepIter<Int_>, IntStepIter<Int_> > >::type honey::range ( Int  begin,
Int2  end,
Int3  step 
)

Create a range that steps through the integral range [begin,end)

template<class Real , class Real2 , class Real3 , class Real_ = typename std::common_type<Real,Real2,Real3>::type>
std::enable_if<std::is_floating_point<Real_>::value, Range_<RealIter<Real_>, RealIter<Real_> > >::type honey::range ( Real  begin,
Real2  end,
Real3  step = 1 
)

Create a range that steps through the real number range [begin,end)

Accum honey::reduce ( Range &&  ,
Seqs &&  ...,
Accum &&  initVal,
Func &&   
)

Accumulate a series of sequences into an output.

Call function for each element in the range and any sequences, f(accum, rangeElem, seq1Elem, seq2Elem...), forwarding the result of each call into the next as accum. Returns the accumulated value.

Reduce can be specialized through the function: priv::reduce_impl<Range, Accum, Seqs...>::func(...)

template<class Range >
auto honey::reversed ( Range &&  range) -> Range_<std::reverse_iterator<mt_iterOf(range)>, std::reverse_iterator<mt_iter_endOf(range)>>

Reverse a range. Begin/End iterators must be bidirectional.

template<class Range , class Iter >
auto honey::ringRange ( Range &&  range,
const Iter &  cur 
) -> Range_<RingIter<Range,Iter>, RingIter<Range,Iter>>

Create an iterator adapter range that does one full cyclic loop starting at cur through the range.

template<class Iter >
auto honey::seqToIter ( Iter &&  seq) -> typename std::enable_if<mt::isIterator<Iter>::value, Iter&&>::type

Convert a sequence to a forward iterator. Overload for iterator type. Returns the iterator itself.

A sequence is defined as anything convertible to a forward iterator (eg. an iterator, a range).

template<class Range >
auto honey::seqToIter ( Range &&  seq) -> typename std::enable_if<mt::isRange<Range>::value, mt_iterOf(seq)>::type

Convert a sequence to a forward iterator. Overload for range type. Returns the range's begin iterator.