1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef CR_HASH_H
|
---|
8 | #define CR_HASH_H
|
---|
9 |
|
---|
10 | #include "chromium.h"
|
---|
11 |
|
---|
12 | #include <iprt/cdefs.h>
|
---|
13 |
|
---|
14 | #ifdef __cplusplus
|
---|
15 | extern "C" {
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | typedef struct CRHashIdPool CRHashIdPool;
|
---|
19 | typedef struct CRHashTable CRHashTable;
|
---|
20 |
|
---|
21 | /* Callback function used for freeing/deleting table entries */
|
---|
22 | typedef void (*CRHashtableCallback)(void *data);
|
---|
23 | typedef void (*CRHashtableCallbackEx)(void *data1, void *data2);
|
---|
24 | /* Callback function used for walking through table entries */
|
---|
25 | typedef void (*CRHashtableWalkCallback)(unsigned long key, void *data1, void *data2);
|
---|
26 | /* Callback function used for walking through allocated keys */
|
---|
27 | typedef void (*CRHashIdWalkKeys)(unsigned long firstKey, unsigned long count, void *data);
|
---|
28 |
|
---|
29 | DECLEXPORT(CRHashIdPool *) crAllocHashIdPool( void );
|
---|
30 | DECLEXPORT(CRHashIdPool *) crAllocHashIdPoolEx( GLuint min, GLuint max );
|
---|
31 | DECLEXPORT(void) crFreeHashIdPool( CRHashIdPool *pool );
|
---|
32 | DECLEXPORT(GLboolean) crHashIdPoolIsIdFree( const CRHashIdPool *pool, GLuint id );
|
---|
33 | DECLEXPORT(GLuint) crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count );
|
---|
34 | DECLEXPORT(void) crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count );
|
---|
35 | /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
|
---|
36 | DECLEXPORT(GLboolean) crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id );
|
---|
37 | DECLEXPORT(void) crHashIdWalkKeys( CRHashIdPool *pool, CRHashIdWalkKeys walkFunc , void *data);
|
---|
38 |
|
---|
39 | DECLEXPORT(CRHashTable *) crAllocHashtable( void );
|
---|
40 | DECLEXPORT(CRHashTable *) crAllocHashtableEx( GLuint min, GLuint max );
|
---|
41 | DECLEXPORT(void) crFreeHashtable( CRHashTable *hash, CRHashtableCallback deleteCallback );
|
---|
42 | DECLEXPORT(void) crFreeHashtableEx( CRHashTable *hash, CRHashtableCallbackEx deleteCallback, void *pData );
|
---|
43 | DECLEXPORT(void) crHashtableAdd( CRHashTable *h, unsigned long key, void *data );
|
---|
44 | /* to ensure hash table pool id consistency, there is no crHashTableFreeKeys/UnregisterKey,
|
---|
45 | * one should call crHashtableDelete to free unneeded keys,
|
---|
46 | * which will also ensure there is no entry with the specified key left in the table */
|
---|
47 | DECLEXPORT(GLuint) crHashtableAllocKeys( CRHashTable *h, GLsizei range );
|
---|
48 | /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
|
---|
49 | DECLEXPORT(GLboolean) crHashtableAllocRegisterKey( CRHashTable *h, GLuint key);
|
---|
50 | DECLEXPORT(void) crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteCallback );
|
---|
51 | DECLEXPORT(void) crHashtableDeleteEx( CRHashTable *h, unsigned long key, CRHashtableCallbackEx deleteCallback, void *pData );
|
---|
52 | DECLEXPORT(void) crHashtableDeleteBlock( CRHashTable *h, unsigned long key, GLsizei range, CRHashtableCallback deleteFunc );
|
---|
53 | DECLEXPORT(void *) crHashtableSearch( const CRHashTable *h, unsigned long key );
|
---|
54 | DECLEXPORT(void) crHashtableReplace( CRHashTable *h, unsigned long key, void *data, CRHashtableCallback deleteFunc);
|
---|
55 | DECLEXPORT(unsigned int) crHashtableNumElements( const CRHashTable *h) ;
|
---|
56 | DECLEXPORT(GLboolean) crHashtableIsKeyUsed( const CRHashTable *h, GLuint id );
|
---|
57 | DECLEXPORT(void) crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
|
---|
58 | /* walk the hashtable w/o holding the table lock */
|
---|
59 | DECLEXPORT(void) crHashtableWalkUnlocked( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
|
---|
60 | /*Returns GL_TRUE if given hashtable hold the data, pKey is updated with key value for data in this case*/
|
---|
61 | DECLEXPORT(GLboolean) crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey);
|
---|
62 | DECLEXPORT(void) crHashtableLock(CRHashTable *h);
|
---|
63 | DECLEXPORT(void) crHashtableUnlock(CRHashTable *h);
|
---|
64 | DECLEXPORT(void) crHashtableWalkKeys(CRHashTable *hash, CRHashIdWalkKeys walkFunc , void *data);
|
---|
65 |
|
---|
66 | #ifdef __cplusplus
|
---|
67 | } /* extern "C" */
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #endif /* CR_HASH_H */
|
---|