Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site

SourceForge.net Logo



U++ algorithms are designed to work on Ranges. Range is a type that has (at minimum)


Standard begin() / end() methods.

GetCount() that returns the number of elements in Range (can be implemented as end - begin)

operator[] (can be implemented as begin()[i])


Standard Ranges usually also implement ToString and comparisons (if it is possible).


Usually, Range is either U++ container or just some part of it.


U++ provides these Range related typedefs and template functions:



template <class Range> using ValueTypeOf;

Returns the type of elements of Range.



template <class Range> using IteratorOf;

template <class Range> using ConstIteratorOf'

Returns the type of Iterator / ConstIterator of range.



template <class I

SubRangeClass<ISubRange(I begin, I end)

Makes a Range based on begin/end iterators.



template <class I

SubRangeClass<ISubRange(I begin, int count)

Makes a Range based on begin iterator and count.



template <class C

auto SubRange(C& c, int pos, int count);

template <class C>

auto SubRange(C&& c, int pos, int count);

Makes a Range as subrange of some other Range (e.g. container).



template <class Range> using SubRangeOf;

Returns the type of SubRange of some Range.



template <class T

ConstRangeClass<TConstRange(const T& value, int count)

Creates a Range of count elements equal to value.



template <class T

ConstRangeClass<TConstRange(int count)

Creates a Range of count default constructed elements T.



template <class BaseRange

ReverseRangeClass<BaseRangeReverseRange(BaseRange& r)

template <class BaseRange

ReverseRangeClass<BaseRangeReverseRange(BaseRange&& r)

Makes a Range reverting the order of elements of r. First element of r becomes the last element of ReverseRange etc..



template <class BaseRange

ViewRangeClass<BaseRangeViewRange(BaseRange& r, Vector<int>&& ndx)

template <class BaseRange

ViewRangeClass<BaseRangeViewRange(BaseRange&& r, Vector<int>&& ndx)

Creates a view of BaseRange r based on mapping ndx. Element at ndx[0] becomes a first element of a new Range, ndx[1] second etc..



template <class BaseRange, class Predicate

ViewRangeClass<BaseRangeFilterRange(BaseRange& r, Predicate p)

template <class BaseRange, class Predicate

ViewRangeClass<BaseRangeFilterRange(BaseRange&& r, Predicate p)

Same as ViewRangeClass<BaseRange>(r, FindAll(r, p)). Creates a view of elements of master Range that satisfy condition p.



template <class BaseRange, class Predicate>

ViewRangeClass<BaseRangeSortedRange(BaseRange& r, Predicate p)

template <class BaseRange, class Predicate

ViewRangeClass<BaseRangeSortedRange(BaseRange&& r, Predicate p)

Returns a view of range r sorted by predicate p.



template <class BaseRange

ViewRangeClass<BaseRangeSortedRange(BaseRange& r)

template <class BaseRange

ViewRangeClass<BaseRangeSortedRange(BaseRange&& r)

Returns a view of range r sorted by std::less predicate.


Last edit by cxl on 06/04/2017. Do you want to contribute?. T++