Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/general/sort.hpp
3206 views
1
#ifndef FILE_SORT
2
#define FILE_SORT
3
4
/**************************************************************************/
5
/* File: sort.hh */
6
/* Author: Joachim Schoeberl */
7
/* Date: 07. Jan. 00 */
8
/**************************************************************************/
9
10
11
// order(i) is sorted index of element i
12
extern void Sort (const ARRAY<double> & values,
13
ARRAY<int> & order);
14
15
extern void QickSort (const ARRAY<double> & values,
16
ARRAY<int> & order);
17
18
19
20
21
template <class T>
22
inline void BubbleSort (int size, T * data)
23
{
24
T hv;
25
for (int i = 0; i < size; i++)
26
for (int j = i+1; j < size; j++)
27
if (data[i] > data[j])
28
{
29
hv = data[i];
30
data[i] = data[j];
31
data[j] = hv;
32
}
33
}
34
35
template <class T>
36
inline void BubbleSort (ARRAY<T> & data)
37
{
38
if(data.Size() > 0)
39
BubbleSort (data.Size(), &data[data.Begin()]);
40
}
41
42
#endif
43
44