Scippy

GCG

Branch-and-Price & Column Generation for Everyone

gcgsort.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
4 /* GCG --- Generic Column Generation */
5 /* a Dantzig-Wolfe decomposition based extension */
6 /* of the branch-cut-and-price framework */
7 /* SCIP --- Solving Constraint Integer Programs */
8 /* */
9 /* Copyright (C) 2010-2021 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
28 /**@file gcgsort.h
29  * @brief sorting functions, adapted from SCIP's sorttpl to include userdata
30  * @author Tobias Oelschlegel
31  **/
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #ifndef GCG_SORT_H__
36 #define GCG_SORT_H__
37 
38 #include "scip/scip.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /** compares two element indices
45  * result:
46  * < 0: ind1 comes before (is better than) ind2
47  * = 0: both indices have the same value
48  * > 0: ind2 comes after (is worse than) ind2
49  **/
50 #define GCG_DECL_SORTINDCOMP(x) int x (void* userdata, void* dataptr, int ind1, int ind2)
51 
52 /** compares two data element pointers
53  * result:
54  * < 0: elem1 comes before (is better than) elem2
55  * = 0: both elements have the same value
56  * > 0: elem2 comes after (is worse than) elem2
57  **/
58 #define GCG_DECL_SORTPTRCOMP(x) int x (void* userdata, void* elem1, void* elem2)
59 
60 SCIP_EXPORT
61 void GCGsortPtr(
62  void** ptrarray, /**< pointer array to be sorted */
63  GCG_DECL_SORTPTRCOMP((*ptrcomp)), /**< data element comparator */
64  void* userdata, /**< userdata that is supplied to the comparator function */
65  int len /**< length of array */
66  );
67 
68 /** sort of two joint arrays of pointers/pointers, sorted by first array in non-decreasing order */
69 SCIP_EXPORT
70 void GCGsortPtrPtr(
71  void** ptrarray1, /**< first pointer array to be sorted */
72  void** ptrarray2, /**< second pointer array to be permuted in the same way */
73  GCG_DECL_SORTPTRCOMP((*ptrcomp)), /**< data element comparator */
74  void* userdata, /**< userdata that is supplied to the comparator function */
75  int len /**< length of arrays */
76  );
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif
#define GCG_DECL_SORTPTRCOMP(x)
Definition: gcgsort.h:58
SCIP_EXPORT void GCGsortPtr(void **ptrarray, GCG_DECL_SORTPTRCOMP((*ptrcomp)), void *userdata, int len)
SCIP_EXPORT void GCGsortPtrPtr(void **ptrarray1, void **ptrarray2, GCG_DECL_SORTPTRCOMP((*ptrcomp)), void *userdata, int len)