philsupertramp/game-math
Loading...
Searching...
No Matches
Functions
sorting.h File Reference
#include "Matrix.h"
#include <type_traits>
#include <vector>

Go to the source code of this file.

Functions

template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
void insertion_sort (const T &elem, std::vector< T > &vec, const int &current_index)
 
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
std::vector< T > sort (const std::vector< T > &in)
 
template<typename T >
void insertion_sort (const T &elem, Matrix< T > &out, const int &current_index)
 
template<typename T >
Matrix< T > sort (const Matrix< T > &in)
 

Function Documentation

◆ insertion_sort() [1/2]

template<typename T >
void insertion_sort ( const T &  elem,
Matrix< T > &  out,
const int &  current_index 
)

◆ insertion_sort() [2/2]

template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
void insertion_sort ( const T &  elem,
std::vector< T > &  vec,
const int &  current_index 
)

Insertion sort for numerical vectors of type T

Template Parameters
Tinput value type
Parameters
elemelement to insert into given vector
vecgiven vector to add the element to
current_indexvector index of last element

◆ sort() [1/2]

template<typename T >
Matrix< T > sort ( const Matrix< T > &  in)

◆ sort() [2/2]

template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
std::vector< T > sort ( const std::vector< T > &  in)

Sort given vector of elements of numerical type T

currently using insertion sort, might change at some point

Template Parameters
Telement type
Parameters
ininput vector
Returns
sorted vector with ascending values
Examples
TestSorting.cpp.