EFL 1.7 svn doobies
[profile/ivi/eina.git] / src / include / eina_inline_rbtree.x
1 /* EINA - EFL data type library
2  * Copyright (C) 2002-2008 Cedric BAIL
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library;
16  * if not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef EINA_RBTREE_INLINE_H_
20 #define EINA_RBTREE_INLINE_H_
21
22 /**
23  * @addtogroup Eina_Rbtree_Group Red-Black tree
24  *
25  * @brief These functions provide Red-Black trees management.
26  *
27  * @{
28  */
29
30 static inline Eina_Rbtree *
31 eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data)
32 {
33    int result;
34
35    while (root)
36      {
37         result = cmp(root, key, length, (void*) data);
38         if (result == 0) return (Eina_Rbtree*) root;
39
40         root = root->son[result < 0 ? 0 : 1];
41      }
42
43    return NULL;
44 }
45
46 /**
47  * @}
48  */
49
50 #endif