src/base/cs_search.h Source File

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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-2013 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 #include "cs_defs.h"
31
32 /*----------------------------------------------------------------------------
33 * Local headers
34 *---------------------------------------------------------------------------*/
35
36 #include "cs_base.h"
37
38 /*---------------------------------------------------------------------------*/
39
40 BEGIN_C_DECLS
41
42 /*============================================================================
43 * Macro and type definitions
44 *===========================================================================*/
45
46 /*============================================================================
47 * Public function prototypes
48 *===========================================================================*/
49
50 /*----------------------------------------------------------------------------
51 * Get the position inside an array related to a value thanks to a binary
52 * search. Array or list must be ordered.
53 *
54 * parameters:
55 * size <-- size of list
56 * gnum <-- find index for this number
57 * lst <-- list of ordered global numbers to scan
58 *
59 * returns:
60 * id associated to the current number. If not found, returned -1.
61 *---------------------------------------------------------------------------*/
62
63 int
64 cs_search_g_binary(size_t size,
65 cs_gnum_t gnum,
66 const cs_gnum_t lst[]);
67
68 /*----------------------------------------------------------------------------
69 * Get the position inside an array related to a value thanks to a binary
70 * search (binary search). Array or list must be ordered.
71 *
72 * parameters:
73 * size <-- size of list
74 * num <-- find index for this number
75 * lst <-- list of ordered numbers to scan
76 *
77 * returns:
78 * id associated to the current number. If not found, return -1.
79 *---------------------------------------------------------------------------*/
80
81 int
82 cs_search_binary(size_t size,
83 cs_lnum_t num,
84 const cs_lnum_t lst[]);
85
86 /*----------------------------------------------------------------------------
87 * Get the position inside an array related to a value thanks to a binary
88 * search (binary search). Index must be ordered and without null range.
89 *
90 * parameters:
91 * size <-- size of index -1
92 * gnum <-- number for which we want the position in index
93 * index <-- index array
94 *
95 * returns:
96 * id in index of gnum. If not found, returned -1.
97 *---------------------------------------------------------------------------*/
98
99 int
100 cs_search_gindex_binary(size_t size,
101 cs_gnum_t gnum,
102 const cs_gnum_t index[]);
103
104 /*---------------------------------------------------------------------------*/
105
106 END_C_DECLS
107
108 #endif /* __CS_SEARCH_H__ */