Macros | Typedefs | Functions
vbl_qsort.h File Reference

Collection of common predicates for library sort routines. More...

#include <algorithm>
#include <vector>
#include <cstdlib>
#include <vbl/vbl_sort.h>

Go to the source code of this file.

Macros

#define vbl_qsort_double_ascending   vbl_sort_double_ascending
 
#define vbl_qsort_double_descending   vbl_sort_double_descending
 
#define vbl_qsort_int_ascending   vbl_sort_int_ascending
 
#define vbl_qsort_int_descending   vbl_sort_int_descending
 
#define vbl_qsort_helper   vbl_sort_helper
 
#define VBL_QSORT_INSTANTIATE(T)
 
#define VBL_QSORT_INSTANTIATE_vector(T)
 

Typedefs

typedef int(* vbl_qsort_compare_t) (const void *a, const void *b)
 

Functions

template<class T >
void vbl_qsort_ascending (T *base, int n)
 Sort a C array into ascending order. More...
 
template<class T >
void vbl_qsort_descending (T *base, int n)
 Sort a C array into descending order. More...
 
template<class T >
void vbl_qsort_ascending (std::vector< T > &v)
 Sort an STL vector into ascending order. More...
 
template<class T >
void vbl_qsort_descending (std::vector< T > &v)
 Sort an STL vector into descending order. More...
 
template<class T >
void vbl_qsort (std::vector< T > &v, int(*compare)(T const &a, T const &b))
 Sort STL vector. More...
 

Detailed Description

Collection of common predicates for library sort routines.

Author
awf@r.nosp@m.obot.nosp@m.s.ox..nosp@m.ac.u.nosp@m.k
Date
15 Mar 00
  Modifications
   971119 AWF Initial version
   PDA (Manchester) 23/03/2001: Tidied up the documentation
   Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line

Definition in file vbl_qsort.h.

Macro Definition Documentation

◆ vbl_qsort_double_ascending

#define vbl_qsort_double_ascending   vbl_sort_double_ascending

Definition at line 27 of file vbl_qsort.h.

◆ vbl_qsort_double_descending

#define vbl_qsort_double_descending   vbl_sort_double_descending

Definition at line 28 of file vbl_qsort.h.

◆ vbl_qsort_helper

#define vbl_qsort_helper   vbl_sort_helper

Definition at line 31 of file vbl_qsort.h.

◆ VBL_QSORT_INSTANTIATE

#define VBL_QSORT_INSTANTIATE (   T)
Value:
/*template void vbl_qsort_ascending((T)*,int); */\
/*template void vbl_qsort_descending((T)*,int) */

Definition at line 84 of file vbl_qsort.h.

◆ VBL_QSORT_INSTANTIATE_vector

#define VBL_QSORT_INSTANTIATE_vector (   T)
Value:
/* template void vbl_qsort(std::vector<T >& v, \
int (*compare)(T const& a, T const& b)) */

Definition at line 88 of file vbl_qsort.h.

◆ vbl_qsort_int_ascending

#define vbl_qsort_int_ascending   vbl_sort_int_ascending

Definition at line 29 of file vbl_qsort.h.

◆ vbl_qsort_int_descending

#define vbl_qsort_int_descending   vbl_sort_int_descending

Definition at line 30 of file vbl_qsort.h.

Typedef Documentation

◆ vbl_qsort_compare_t

typedef int(* vbl_qsort_compare_t) (const void *a, const void *b)

Definition at line 33 of file vbl_qsort.h.

Function Documentation

◆ vbl_qsort()

template<class T >
void vbl_qsort ( std::vector< T > &  v,
int(*)(T const &a, T const &b)  compare 
)
inline

Sort STL vector.

Definition at line 79 of file vbl_qsort.h.

◆ vbl_qsort_ascending() [1/2]

template<class T >
void vbl_qsort_ascending ( T *  base,
int  n 
)
inline

Sort a C array into ascending order.

Do this using the standard comparison operations for T, namely operator> and operator==.

Definition at line 40 of file vbl_qsort.h.

◆ vbl_qsort_ascending() [2/2]

template<class T >
void vbl_qsort_ascending ( std::vector< T > &  v)
inline

Sort an STL vector into ascending order.

Do this using the standard comparison operations for T, namely operator> and operator==. I know STL has a sort, but this is easier, and faster in the 21st century.

Definition at line 61 of file vbl_qsort.h.

◆ vbl_qsort_descending() [1/2]

template<class T >
void vbl_qsort_descending ( T *  base,
int  n 
)
inline

Sort a C array into descending order.

Do this using the standard comparison operations for T, namely "operator>" and "operator==".

Definition at line 50 of file vbl_qsort.h.

◆ vbl_qsort_descending() [2/2]

template<class T >
void vbl_qsort_descending ( std::vector< T > &  v)
inline

Sort an STL vector into descending order.

Do this using the standard comparison operations for T, namely "operator>" and "operator==".

Definition at line 71 of file vbl_qsort.h.