ivsort.cpp (revision 795)
3 3
``` *
```
4 4
``` * Copyright (c) 2009 ADMB Foundation
```
5 5
``` */
```
6
```/**
```
7
``` * \file
```
8
``` * Has routines for sorting an ivector
```
9
``` */
```
10

6 11
```#include <fvar.hpp>
```
7 12
```#include "qsort.h"
```
8 13

9
```void int_qsort(int *arr, unsigned n) {
```
14
```/**
```
15
``` * A subroutine used in Quicksort
```
16
``` */
```
17
```void int_qsort(int *arr, unsigned n)
```
18
```{
```
10 19
```  #define int_lt(a,b) ((*a)<(*b))
```
11
```    QSORT(int, arr, n, int_lt);
```
12
```  }
```
20
```  QSORT(int, arr, n, int_lt);
```
21
```}
```
13 22

14
```void int_qsort2(int *arr, int *arr2, unsigned n) {
```
23
```/**
```
24
``` * A subroutine used in Quicksort
```
25
``` */
```
26
```void int_qsort2(int *arr, int *arr2, unsigned n)
```
27
```{
```
15 28
```  #define int_lt(a,b) ((*a)<(*b))
```
16
```    QSORT2(int, int, arr, arr2, n, int_lt);
```
17
```  }
```
29
```  QSORT2(int, int, arr, arr2, n, int_lt);
```
30
```}
```
18 31

19
```/** Quicksort.
```
20
```    \param v Vector of integers to be sorted
```
21
```    \param NSTACK Not used.
```
22
```    \return ivector object containing the input vector sorted in ascending order.
```
23

24
```    \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
```
25
```*/
```
32
```/**
```
33
``` * Quicksort.
```
34
``` * \param v Vector of integers to be sorted
```
35
``` * \param NSTACK Not used.
```
36
``` * \return ivector object containing the input vector sorted in ascending order.
```
37
``` *
```
38
``` * \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
```
39
``` */
```
26 40
```ivector sort(_CONST ivector & v, int NSTACK)
```
27 41
```{
```
28 42
```   int lb=v.indexmin();
```
......
49 63
```   return arr;
```
50 64
```}
```
51 65

52
```/** Quicksort.
```
53
```    \param _v Vector of integers to be sorted
```
54
```    \param _index ivector on return containing the input order of the original vector.
```
55
```    \param NSTACK Not used.
```
56
```    \return ivector object containing the input vector sorted in ascending order.
```
57

58
```    \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
```
59
```*/
```
66
```/**
```
67
``` * Quicksort.
```
68
``` * \param _v Vector of integers to be sorted
```
69
``` * \param _index ivector on return containing the input order of the original vector.
```
70
``` * \param NSTACK Not used.
```
71
``` * \return ivector object containing the input vector sorted in ascending order.
```
72
``` *
```
73
``` * \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
```
74
``` */
```
60 75
```ivector sort(_CONST ivector & _v, BOR_CONST ivector & _index, int NSTACK)
```
61 76
```{
```
62 77
```   ivector & index = (ivector &) _index;
```
......
104 119

105 120
```   return arr;
```
106 121
```}
```
107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff