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