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 | /* Callback function used for walking through table entries */
|
---|
24 | typedef void (*CRHashtableWalkCallback)(unsigned long key, void *data1, void *data2);
|
---|
25 | /* Callback function used for walking through allocated keys */
|
---|
26 | typedef void (*CRHashIdWalkKeys)(unsigned long firstKey, unsigned long count, void *data);
|
---|
27 |
|
---|
28 | DECLEXPORT(CRHashIdPool *) crAllocHashIdPool( void );
|
---|
29 | DECLEXPORT(CRHashIdPool *) crAllocHashIdPoolEx( GLuint min, GLuint max );
|
---|
30 | DECLEXPORT(void) crFreeHashIdPool( CRHashIdPool *pool );
|
---|
31 | DECLEXPORT(GLboolean) crHashIdPoolIsIdFree( const CRHashIdPool *pool, GLuint id );
|
---|
32 | DECLEXPORT(GLuint) crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count );
|
---|
33 | DECLEXPORT(void) crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count );
|
---|
34 | /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
|
---|
35 | DECLEXPORT(GLboolean) crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id );
|
---|
36 | DECLEXPORT(void) crHashIdWalkKeys( CRHashIdPool *pool, CRHashIdWalkKeys walkFunc , void *data);
|
---|
37 |
|
---|
38 | DECLEXPORT(CRHashTable *) crAllocHashtable( void );
|
---|
39 | DECLEXPORT(CRHashTable *) crAllocHashtableEx( GLuint min, GLuint max );
|
---|
40 | DECLEXPORT(void) crFreeHashtable( CRHashTable *hash, CRHashtableCallback deleteCallback );
|
---|
41 | DECLEXPORT(void) crHashtableAdd( CRHashTable *h, unsigned long key, void *data );
|
---|
42 | /* to ensure hash table pool id consistency, there is no crHashTableFreeKeys/UnregisterKey,
|
---|
43 | * one should call crHashtableDelete to free unneeded keys,
|
---|
44 | * which will also ensure there is no entry with the specified key left in the table */
|
---|
45 | DECLEXPORT(GLuint) crHashtableAllocKeys( CRHashTable *h, GLsizei range );
|
---|
46 | /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
|
---|
47 | DECLEXPORT(GLboolean) crHashtableAllocRegisterKey( CRHashTable *h, GLuint key);
|
---|
48 | DECLEXPORT(void) crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteCallback );
|
---|
49 | DECLEXPORT(void) crHashtableDeleteBlock( CRHashTable *h, unsigned long key, GLsizei range, CRHashtableCallback deleteFunc );
|
---|
50 | DECLEXPORT(void *) crHashtableSearch( const CRHashTable *h, unsigned long key );
|
---|
51 | DECLEXPORT(void) crHashtableReplace( CRHashTable *h, unsigned long key, void *data, CRHashtableCallback deleteFunc);
|
---|
52 | DECLEXPORT(unsigned int) crHashtableNumElements( const CRHashTable *h) ;
|
---|
53 | DECLEXPORT(GLboolean) crHashtableIsKeyUsed( const CRHashTable *h, GLuint id );
|
---|
54 | DECLEXPORT(void) crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
|
---|
55 | /* walk the hashtable w/o holding the table lock */
|
---|
56 | DECLEXPORT(void) crHashtableWalkUnlocked( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
|
---|
57 | /*Returns GL_TRUE if given hashtable hold the data, pKey is updated with key value for data in this case*/
|
---|
58 | DECLEXPORT(GLboolean) crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey);
|
---|
59 | DECLEXPORT(void) crHashtableLock(CRHashTable *h);
|
---|
60 | DECLEXPORT(void) crHashtableUnlock(CRHashTable *h);
|
---|
61 | DECLEXPORT(void) crHashtableWalkKeys(CRHashTable *hash, CRHashIdWalkKeys walkFunc , void *data);
|
---|
62 |
|
---|
63 | #ifdef __cplusplus
|
---|
64 | } /* extern "C" */
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #endif /* CR_HASH_H */
|
---|