tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sort.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * sort.h
4  *
5  * =============================================================================
6  *
7  * Quick sort
8  *
9  * Copyright (C) 2002 Michael Ringgaard. All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the project nor the names of its contributors
21  * may be used to endorse or promote products derived from this software
22  * without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE
35  *
36  * =============================================================================
37  *
38  * Modifed October 2007 by Chi Cao Minh
39  * -- Changed signature of comparison function
40  *
41  * =============================================================================
42  *
43  * For the license of bayes/sort.h and bayes/sort.c, please see the header
44  * of the files.
45  *
46  * ------------------------------------------------------------------------
47  *
48  * For the license of kmeans, please see kmeans/LICENSE.kmeans
49  *
50  * ------------------------------------------------------------------------
51  *
52  * For the license of ssca2, please see ssca2/COPYRIGHT
53  *
54  * ------------------------------------------------------------------------
55  *
56  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
57  * header of the files.
58  *
59  * ------------------------------------------------------------------------
60  *
61  * For the license of lib/rbtree.h and lib/rbtree.c, please see
62  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
63  *
64  * ------------------------------------------------------------------------
65  *
66  * Unless otherwise noted, the following license applies to STAMP files:
67  *
68  * Copyright (c) 2007, Stanford University
69  * All rights reserved.
70  *
71  * Redistribution and use in source and binary forms, with or without
72  * modification, are permitted provided that the following conditions are
73  * met:
74  *
75  * * Redistributions of source code must retain the above copyright
76  * notice, this list of conditions and the following disclaimer.
77  *
78  * * Redistributions in binary form must reproduce the above copyright
79  * notice, this list of conditions and the following disclaimer in
80  * the documentation and/or other materials provided with the
81  * distribution.
82  *
83  * * Neither the name of Stanford University nor the names of its
84  * contributors may be used to endorse or promote products derived
85  * from this software without specific prior written permission.
86  *
87  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
88  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
89  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
91  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
92  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
93  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
94  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
95  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
97  * THE POSSIBILITY OF SUCH DAMAGE.
98  *
99  * =============================================================================
100  */
101 
102 
103 #ifndef SORT_H
104 #define SORT_H 1
105 
106 
107 /* =============================================================================
108  * sort
109  * =============================================================================
110  */
111 void
112 sort (void* base,
113  unsigned num,
114  unsigned width,
115  int (*cmp)(const void* p1, const void* p2, long n, long offset),
116  long n,
117  long offset);
118 
119 
120 #endif /* SORT_H */
121 
122 
123 /* =============================================================================
124  *
125  * End of sort.h
126  *
127  * =============================================================================
128  */
void sort(void *base, unsigned num, unsigned width, int(*cmp)(const void *p1, const void *p2, long n, long offset), long n, long offset)
Definition: sort.c:155