Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
Bial::Sorting Namespace Reference

Extensions for sorting methods. More...

Functions

template<template< class D > class C, class D >
size_t BinarySearch (const C< D > &data, D val, size_t min=0)
 First vector index found in a binary search for 'val' in 'data' vector between min and the last indexes (extremities included). If the 'data' does not have any 'val' element, the function returns the next index to the expected position, limited by the index range. More...
 
template<template< class D > class C, class D >
size_t BinarySearch (const C< D > &data, D val, size_t min, size_t max)
 First vector index found in a binary search for 'val' in 'data' vector between min and max indexes (extremities included). If the 'data' does not have any 'val' element, the function returns the next index to the expected position, limited by the index range. More...
 
template<template< class D > class C, class D >
void Sort (C< D > &data, Vector< size_t > &order, size_t min_idx, size_t max_idx, bool increasing)
 Auxiliary recursive function for quick sort. More...
 
template<template< class D > class C, class D >
Vector< size_t > Sort (C< D > &data, bool increasing=true)
 Sorts data and returns a Vector with the sorted indexes. More...
 
template<template< class D > class C, class D >
void Sort (C< D > &data, const Vector< size_t > &order)
 Sorts data according to the sorting indexes in order vector. May be used with the return vector of Sort( C< D > &data, bool increasing ) function to sort other containers in the same order. More...
 

Detailed Description

Extensions for sorting methods.

Function Documentation

template<template< class D > class C, class D >
size_t Bial::Sorting::BinarySearch ( const C< D > &  data,
val,
size_t  min = 0 
)

First vector index found in a binary search for 'val' in 'data' vector between min and the last indexes (extremities included). If the 'data' does not have any 'val' element, the function returns the next index to the expected position, limited by the index range.

Date
2013/Oct/04
Parameters
dataA sorted random access data structure that implements size( ) and operator[]( size_t ) functions. E.G. Vector, std::deque, Matrix, Image.
valValue to be found.
minMinimum search index.
Returns
A vector index.
Warning
none.
template<template< class D > class C, class D >
size_t Bial::Sorting::BinarySearch ( const C< D > &  data,
val,
size_t  min,
size_t  max 
)

First vector index found in a binary search for 'val' in 'data' vector between min and max indexes (extremities included). If the 'data' does not have any 'val' element, the function returns the next index to the expected position, limited by the index range.

Date
2013/Oct/04
Parameters
dataA sorted random access data structure that implements size( ) and operator[]( size_t ) functions. E.G. Vector, std::deque, Matrix, Image.
valValue to be found.
minMinimum search index.
maxMaximum search index.
Returns
A vector index.
Warning
none.
template<template< class D > class C, class D >
void Bial::Sorting::Sort ( C< D > &  data,
Vector< size_t > &  order,
size_t  min_idx,
size_t  max_idx,
bool  increasing 
)

Auxiliary recursive function for quick sort.

Date
2013/Dec/11
Parameters
dataA random access data structure that implements size( ) and operator[]( size_t ) functions. E.G. Vector, std::deque, Matrix, Image.
min_idxMinimum index of the elements to be sorted.
max_idxMaximum index of the elements to be sorted.
increasingIf sorting in increasing or decreasing order.
Returns
Vector with the sorted indexes.
Warning
Do not call this function. Use the other sort functions in this file.
template<template< class D > class C, class D >
Vector< size_t > Bial::Sorting::Sort ( C< D > &  data,
bool  increasing = true 
)

Sorts data and returns a Vector with the sorted indexes.

Date
2013/Sep/04
Parameters
dataA random access data structure that implements size( ) and operator[]( size_t ) functions. E.G. Vector, std::deque, Matrix, Image.
increasingIf sorting in increasing or decreasing order.
Returns
Vector with the sorted indexes.
Warning
none.
template<template< class D > class C, class D >
void Bial::Sorting::Sort ( C< D > &  data,
const Vector< size_t > &  order 
)

Sorts data according to the sorting indexes in order vector. May be used with the return vector of Sort( C< D > &data, bool increasing ) function to sort other containers in the same order.

Date
2013/Sep/04
Parameters
dataA random access data structure that implements size( ) and operator[]( size_t ) functions. E.G. Vector, std::deque, Matrix, Image.
ordervector with the sorting indexes.
Returns
none.
Warning
none.