~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to src/base/cs_search.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2011 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
 
 
44
BEGIN_C_DECLS
 
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
                   fvm_gnum_t         gnum,
 
70
                   const fvm_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
                        fvm_gnum_t         gnum,
 
106
                        const fvm_gnum_t   index[]);
 
107
 
 
108
/*---------------------------------------------------------------------------*/
 
109
 
 
110
END_C_DECLS
 
111
 
 
112
#endif /* __CS_SEARCH_H__ */