Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cs_search.h
Go to the documentation of this file.
1 #ifndef __CS_SEARCH_H__
2 #define __CS_SEARCH_H__
3 
4 /*============================================================================
5  * Search elements in arrays
6  *===========================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2012 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * FVM library headers
32  *---------------------------------------------------------------------------*/
33 
34 #include <fvm_defs.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *---------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 
42 /*---------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro and type definitions
48  *===========================================================================*/
49 
50 /*============================================================================
51  * Public function prototypes
52  *===========================================================================*/
53 
54 /*----------------------------------------------------------------------------
55  * Get the position inside an array related to a value thanks to a binary
56  * search. Array or list must be ordered.
57  *
58  * parameters:
59  * size <-- size of list
60  * gnum <-- find index for this number
61  * lst <-- list of ordered global numbers to scan
62  *
63  * returns:
64  * id associated to the current number. If not found, returned -1.
65  *---------------------------------------------------------------------------*/
66 
67 int
68 cs_search_g_binary(size_t size,
69  cs_gnum_t gnum,
70  const cs_gnum_t lst[]);
71 
72 /*----------------------------------------------------------------------------
73  * Get the position inside an array related to a value thanks to a binary
74  * search (binary search). Array or list must be ordered.
75  *
76  * parameters:
77  * size <-- size of list
78  * num <-- find index for this number
79  * lst <-- list of ordered numbers to scan
80  *
81  * returns:
82  * id associated to the current number. If not found, return -1.
83  *---------------------------------------------------------------------------*/
84 
85 int
86 cs_search_binary(size_t size,
87  cs_int_t num,
88  const cs_int_t lst[]);
89 
90 /*----------------------------------------------------------------------------
91  * Get the position inside an array related to a value thanks to a binary
92  * search (binary search). Index must be ordered and without null range.
93  *
94  * parameters:
95  * size <-- size of index -1
96  * gnum <-- number for which we want the position in index
97  * index <-- index array
98  *
99  * returns:
100  * id in index of gnum. If not found, returned -1.
101  *---------------------------------------------------------------------------*/
102 
103 int
104 cs_search_gindex_binary(size_t size,
105  cs_gnum_t gnum,
106  const cs_gnum_t index[]);
107 
108 /*---------------------------------------------------------------------------*/
109 
111 
112 #endif /* __CS_SEARCH_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
int cs_int_t
Definition: cs_defs.h:263
BEGIN_C_DECLS int cs_search_g_binary(size_t size, cs_gnum_t gnum, const cs_gnum_t lst[])
Definition: cs_search.c:202
unsigned cs_gnum_t
Definition: cs_defs.h:255
int cs_search_binary(size_t size, cs_int_t num, const cs_int_t lst[])
Definition: cs_search.c:223
#define END_C_DECLS
Definition: cs_defs.h:366
int cs_search_gindex_binary(size_t size, cs_gnum_t gnum, const cs_gnum_t index[])
Definition: cs_search.c:244