ATLAS Offline Software
HashTable.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef HEPHAESTUS_HASHTABLE_H
6 #define HEPHAESTUS_HASHTABLE_H
7 
8 /*
9  Trivial memory-address based hash table
10 */
11 
12 #include <pthread.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 struct hhh_Cell {
19  void *key;
20  void *value;
21 
22  struct hhh_Cell *next;
23 };
24 
25 struct hhh_HashTable {
26  pthread_mutex_t lock;
27 
28  struct hhh_Cell **table;
29 
30  unsigned int size;
31  unsigned int nentries;
32 
34 };
35 
36 
37 /* create a new hash table of at least size minsize */
38 struct hhh_HashTable *hhh_HashTable_new( unsigned long minsize );
39 
40 /* insert pair (key, value); return 0 on failure */
41 int hhh_HashTable_insert( struct hhh_HashTable *ht, void *key, void *value );
42 
43 /* remove pair (key, value) from table; return 0 on failure */
45  struct hhh_HashTable *ht, void *key, void (*cleanup)( void *ptr ) );
46 
47 /* find value for pair; return NULL if not found */
48 void *hhh_HashTable_find( struct hhh_HashTable *ht, void *key );
49 
50 /* merge one hash table into another */
51 int hhh_HashTable_merge( struct hhh_HashTable *into, struct hhh_HashTable *from );
52 
53 /* delete table and (optional) contents */
54 void hhh_HashTable_delete( struct hhh_HashTable *ht, void (*cleanup)( void *ptr ) );
55 
56 #ifdef __cplusplus
57 } /* extern "C" */
58 #endif
59 
60 #endif /* !HEPHAESTUS_HASHTABLE_H */
hhh_HashTable_remove
int hhh_HashTable_remove(struct hhh_HashTable *ht, void *key, void(*cleanup)(void *ptr))
hhh_HashTable::nentries
unsigned int nentries
Definition: HashTable.h:31
athena.value
value
Definition: athena.py:124
hhh_HashTable::lock
pthread_mutex_t lock
Definition: HashTable.h:26
hhh_HashTable_find
void * hhh_HashTable_find(struct hhh_HashTable *ht, void *key)
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
hhh_HashTable_insert
int hhh_HashTable_insert(struct hhh_HashTable *ht, void *key, void *value)
hhh_Cell::key
void * key
Definition: HashTable.h:19
hhh_Cell::value
void * value
Definition: HashTable.h:20
hhh_HashTable::table
struct hhh_Cell ** table
Definition: HashTable.h:28
hhh_Cell
Definition: HashTable.h:18
hhh_HashTable::size
unsigned int size
Definition: HashTable.h:30
hhh_HashTable::lastfound
struct hhh_Cell * lastfound
Definition: HashTable.h:33
hhh_Cell::next
struct hhh_Cell * next
Definition: HashTable.h:22
hhh_HashTable_new
struct hhh_HashTable * hhh_HashTable_new(unsigned long minsize)
hhh_HashTable_delete
void hhh_HashTable_delete(struct hhh_HashTable *ht, void(*cleanup)(void *ptr))
hhh_HashTable_merge
int hhh_HashTable_merge(struct hhh_HashTable *into, struct hhh_HashTable *from)
hhh_HashTable
Definition: HashTable.h:25
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37