revert it due to dlopen error
[sdk/target/sdbd.git] / src / hashtable.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __HASHTABLE_H
18 #define __HASHTABLE_H
19
20 typedef enum _hashtable_size {
21     ht_size_7,
22     ht_size_13,
23     ht_size_31,
24     ht_size_127,
25     ht_size_1021,
26     ht_size_8191
27 } ht_size_t;
28
29 typedef struct _ht_entry {
30     int key;
31     int value;
32     struct _ht_entry* next;
33 } ht_entry;
34
35 typedef struct _hashtable {
36     int size;
37     ht_entry** table;
38 } hashtable;
39
40 hashtable* hashtable_create ( ht_size_t tablesize );
41 void hashtable_destroy ( hashtable* ht_table );
42
43 // return 1 if put is successful
44 // return 0 if put is failed
45 int hashtable_put ( hashtable* ht_table, int key, int value );
46
47 // return 1 if a entry is found in hash table
48 // return 0 if a entry is not found in hash table
49 // output value is stored in (*value)
50 int hashtable_get ( hashtable* ht_table, int key, int* value );
51
52 #endif // __HASHTABLE_H