Sane C++ Libraries
C++ Platform Abstraction Libraries
Algorithms

🟥 Placeholder library templated where algorithms will be placed (see Algorithms for more details) More...

Classes

struct  SC::Algorithms::smallerThan< T >
 Functor that evaluates to a < b More...
 

Functions

template<typename Iterator , typename BinaryPredicate = smallerThan<typename TypeTraits::RemovePointer<Iterator>::type>>
constexpr void SC::Algorithms::bubbleSort (Iterator first, Iterator last, BinaryPredicate predicate=BinaryPredicate())
 Sorts iterator range according to BinaryPredicate (bubble sort). More...
 
template<typename ForwardIterator , typename UnaryPredicate >
constexpr ForwardIterator SC::Algorithms::findIf (ForwardIterator first, ForwardIterator last, UnaryPredicate &&predicate)
 Find item satisfying the given predicate. More...
 
template<typename ForwardIterator , typename UnaryPredicate >
ForwardIterator SC::Algorithms::removeIf (ForwardIterator first, ForwardIterator last, UnaryPredicate &&predicate)
 Removes all items in the given range, satisfying the given predicate. More...
 
template<typename T >
constexpr const T & SC::min (const T &t1, const T &t2)
 Finds the minimum of two values. More...
 
template<typename T >
constexpr const T & SC::max (const T &t1, const T &t2)
 Finds the maximum of two values. More...
 

Detailed Description

🟥 Placeholder library templated where algorithms will be placed (see Algorithms for more details)

Function Documentation

◆ bubbleSort()

template<typename Iterator , typename BinaryPredicate = smallerThan<typename TypeTraits::RemovePointer<Iterator>::type>>
constexpr void SC::Algorithms::bubbleSort ( Iterator  first,
Iterator  last,
BinaryPredicate  predicate = BinaryPredicate() 
)
constexpr

#include <AlgorithmBubbleSort.h>

Sorts iterator range according to BinaryPredicate (bubble sort).

Template Parameters
IteratorA type that behaves as an iterator (can just be a pointer to element in array / vector)
BinaryPredicateA predicate that takes (a, b) and returns bool (example SC::Algorithms::smallerThan)
Parameters
firstIterator pointing at first element of the range
lastIterator pointing at last element of the array
predicateThe given BinaryPredicate

◆ findIf()

template<typename ForwardIterator , typename UnaryPredicate >
constexpr ForwardIterator SC::Algorithms::findIf ( ForwardIterator  first,
ForwardIterator  last,
UnaryPredicate &&  predicate 
)
constexpr

#include <AlgorithmFind.h>

Find item satisfying the given predicate.

Template Parameters
ForwardIteratorA forward iterator (supports ++ and dereference operators)
UnaryPredicateA lambda or functor predicate with a bool (const T&) operator
Parameters
firstIterator pointing at the first item in the range to check
lastIterator pointing after last item in the range to check
predicateThe functor or lambda predicate that decides if wanted item is found
Returns
Iterator pointing at the found item

◆ max()

template<typename T >
constexpr const T & SC::max ( const T &  t1,
const T &  t2 
)
constexpr

#include <Compiler.h>

Finds the maximum of two values.

◆ min()

template<typename T >
constexpr const T & SC::min ( const T &  t1,
const T &  t2 
)
constexpr

#include <Compiler.h>

Finds the minimum of two values.

◆ removeIf()

template<typename ForwardIterator , typename UnaryPredicate >
ForwardIterator SC::Algorithms::removeIf ( ForwardIterator  first,
ForwardIterator  last,
UnaryPredicate &&  predicate 
)

#include <AlgorithmRemove.h>

Removes all items in the given range, satisfying the given predicate.

Template Parameters
ForwardIteratorA forward iterator (supports ++ and dereference operators)
UnaryPredicateA lambda or functor predicate with a bool (const T&) operator
Parameters
firstIterator pointing at the first item in the range to check
lastIterator pointing after last item in the range to check
predicateThe functor or lambda predicate that decides if current item must be removed
Returns
last