Simple Application Framework  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Functions
Saf::Math::Range Namespace Reference

Mathematical algorithms and functions that execute on a range of elements. More...

Functions

template<class FwdIter , class Val , class Comp >
FwdIter LowerBound (FwdIter begin, FwdIter end, const Val &val, Comp comp)
 Finds the furthermost iterator lb in the range [begin, end] such that for any iterator it in the range [begin, lb) it holds that comp(*it, val) == true.
template<class FwdIter , class Val >
FwdIter LowerBound (FwdIter begin, FwdIter end, const Val &val)
 Finds the furthermost iterator lb in the range [begin, end] such that for any iterator it in the range [begin, lb) it holds that *it < val.
template<class FwdIter >
Type::IteratorTraits< FwdIter >
::ValType 
Product (FwdIter begin, FwdIter end)
 Compute the product of elements in the range [begin, end).
template<class FwdIter >
Type::IteratorTraits< FwdIter >
::ValType 
Sum (FwdIter begin, FwdIter end)
 Compute the sum of elements in the range [begin, end).
template<class FwdIter , class Val , class Comp >
FwdIter UpperBound (FwdIter begin, FwdIter end, const Val &val, Comp comp)
 Finds the furthermost iterator ub in the range [begin, end] such that for any iterator it in the range [begin, ub) it holds that comp(val, *it) == false.
template<class FwdIter , class Val >
FwdIter UpperBound (FwdIter begin, FwdIter end, const Val &val)
 Finds the furthermost iterator ub in the range [begin, end] such that for any iterator it in the range [begin, ub) it holds that !(val < *it).

Detailed Description

Mathematical algorithms and functions that execute on a range of elements.

See also:
Saf::Algo::Range.

Function Documentation

template<class FwdIter , class Val , class Comp >
FwdIter Saf::Math::Range::LowerBound ( FwdIter  begin,
FwdIter  end,
const Val &  val,
Comp  comp 
) [inline]

Finds the furthermost iterator lb in the range [begin, end] such that for any iterator it in the range [begin, lb) it holds that comp(*it, val) == true.

The input range is assumed to be sorted according to the comp predicate.

Properties:

  • Minimum iterator category: Forward.
  • Worst-case time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
  • Number of comparisons: $ \mathcal{O}(\log \mathrm{Range::Distance(begin, end)}) $.
Parameters:
[in]beginIterator to the beginning of the sequence.
[in]endIterator to the end of the sequence.
[in]valThe value.
[in]compComparison predicate (accepting Val as the first parameter).
template<class FwdIter , class Val >
FwdIter Saf::Math::Range::LowerBound ( FwdIter  begin,
FwdIter  end,
const Val &  val 
) [inline]

Finds the furthermost iterator lb in the range [begin, end] such that for any iterator it in the range [begin, lb) it holds that *it < val.

The input range is assumed to be sorted according to the Algo::Predicate::Less predicate.

Properties:

  • Minimum iterator category: Forward.
  • Worst-case time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
  • Number of comparisons: $ \mathcal{O}(\log \mathrm{Range::Distance(begin, end)}) $.
Parameters:
[in]beginIterator to the beginning of the sequence.
[in]endIterator to the end of the sequence.
[in]valThe value.
See also:
Algo::Predicate::Less.
Remarks:
Same as LowerBound(begin, end, Algo::Predicate::Less<Val>()).
template<class FwdIter >
Type::IteratorTraits<FwdIter>::ValType Saf::Math::Range::Product ( FwdIter  begin,
FwdIter  end 
) [inline]

Compute the product of elements in the range [begin, end).

Properties:

  • Minimum iterator category: Forward.
  • Time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
template<class FwdIter >
Type::IteratorTraits<FwdIter>::ValType Saf::Math::Range::Sum ( FwdIter  begin,
FwdIter  end 
) [inline]

Compute the sum of elements in the range [begin, end).

Properties:

  • Minimum iterator category: Forward.
  • Time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
template<class FwdIter , class Val , class Comp >
FwdIter Saf::Math::Range::UpperBound ( FwdIter  begin,
FwdIter  end,
const Val &  val,
Comp  comp 
) [inline]

Finds the furthermost iterator ub in the range [begin, end] such that for any iterator it in the range [begin, ub) it holds that comp(val, *it) == false.

The input range is assumed to be sorted according to the comp predicate.

Properties:

  • Minimum iterator category: Forward.
  • Worst-case time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
  • Number of comparisons: $ \mathcal{O}(\log \mathrm{Range::Distance(begin, end)}) $.
Parameters:
[in]beginIterator to the beginning of the sequence.
[in]endIterator to the end of the sequence.
[in]valThe value.
[in]compComparison predicate (accepting Val as the first parameter).
template<class FwdIter , class Val >
FwdIter Saf::Math::Range::UpperBound ( FwdIter  begin,
FwdIter  end,
const Val &  val 
) [inline]

Finds the furthermost iterator ub in the range [begin, end] such that for any iterator it in the range [begin, ub) it holds that !(val < *it).

The input range is assumed to be sorted according to the Algo::Predicate::Less predicate.

Properties:

  • Minimum iterator category: Forward.
  • Worst-case time complexity: $ \mathcal{O}(\mathrm{Range::Distance(begin, end)}) $.
  • Number of comparisons: $ \mathcal{O}(\log \mathrm{Range::Distance(begin, end)}) $.
Parameters:
[in]beginIterator to the beginning of the sequence.
[in]endIterator to the end of the sequence.
[in]valThe value.
See also:
Algo::Predicate::Less.
Remarks:
Same as UpperBound(begin, end, Algo::Predicate::Less<Val>()).