1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_SEQUENCE_SORt_2_
#define DLIB_SEQUENCE_SORt_2_
#include "sequence_sort_abstract.h"
#include "../algs.h"
#include "../sort.h"
namespace dlib
{
template <
typename seq_base
>
class sequence_sort_2 : public seq_base
{
typedef typename seq_base::type T;
public:
/*!
this is a version of the QuickSort algorithm
this uses the dlib::qsort_array function
!*/
void sort (
);
};
template <
typename seq_base
>
inline void swap (
sequence_sort_2<seq_base>& a,
sequence_sort_2<seq_base>& b
) { a.swap(b); }
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename seq_base
>
void sequence_sort_2<seq_base>::
sort (
)
{
if (this->size() > 1)
{
dlib::qsort_array(*this,0,this->size()-1);
}
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_SEQUENCE_SORt_2_
|