2009-01-13 04:40:13 +05:00
|
|
|
#ifndef FILE_SORT
|
|
|
|
#define FILE_SORT
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
/* File: sort.hh */
|
|
|
|
/* Author: Joachim Schoeberl */
|
|
|
|
/* Date: 07. Jan. 00 */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2009-07-20 14:36:36 +06:00
|
|
|
namespace netgen
|
|
|
|
{
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
// order(i) is sorted index of element i
|
2019-07-09 13:39:16 +05:00
|
|
|
extern void Sort (const NgArray<double> & values,
|
|
|
|
NgArray<int> & order);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
2019-07-09 13:39:16 +05:00
|
|
|
extern void QuickSort (const NgArray<double> & values,
|
|
|
|
NgArray<int> & order);
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
inline void BubbleSort (int size, T * data)
|
|
|
|
{
|
|
|
|
T hv;
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
for (int j = i+1; j < size; j++)
|
|
|
|
if (data[i] > data[j])
|
|
|
|
{
|
|
|
|
hv = data[i];
|
|
|
|
data[i] = data[j];
|
|
|
|
data[j] = hv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2019-07-09 13:39:16 +05:00
|
|
|
inline void BubbleSort (NgArray<T> & data)
|
2009-01-13 04:40:13 +05:00
|
|
|
{
|
|
|
|
if(data.Size() > 0)
|
|
|
|
BubbleSort (data.Size(), &data[data.Begin()]);
|
|
|
|
}
|
|
|
|
|
2009-07-20 14:36:36 +06:00
|
|
|
}
|
|
|
|
|
2009-01-13 04:40:13 +05:00
|
|
|
#endif
|