00001 00164 #ifndef LEGATO_HASHMAP_INCLUDE_GUARD 00165 #define LEGATO_HASHMAP_INCLUDE_GUARD 00166 00167 //-------------------------------------------------------------------------------------------------- 00171 //-------------------------------------------------------------------------------------------------- 00172 typedef struct le_hashmap* le_hashmap_Ref_t; 00173 00174 //-------------------------------------------------------------------------------------------------- 00178 //-------------------------------------------------------------------------------------------------- 00179 typedef struct le_hashmap_It* le_hashmap_It_Ref_t; 00180 00181 //-------------------------------------------------------------------------------------------------- 00189 //-------------------------------------------------------------------------------------------------- 00190 typedef size_t (*le_hashmap_HashFunc_t) 00191 ( 00192 const void* keyToHashPtr 00193 ); 00194 00195 //-------------------------------------------------------------------------------------------------- 00205 //-------------------------------------------------------------------------------------------------- 00206 typedef bool (*le_hashmap_EqualsFunc_t) 00207 ( 00208 const void* firstKeyPtr, 00209 const void* secondKeyPtr 00210 ); 00211 00212 00213 //-------------------------------------------------------------------------------------------------- 00223 //-------------------------------------------------------------------------------------------------- 00224 typedef bool (*le_hashmap_ForEachHandler_t) 00225 ( 00226 const void* keyPtr, 00227 const void* valuePtr, 00228 void* contextPtr 00229 ); 00230 00231 //-------------------------------------------------------------------------------------------------- 00242 //-------------------------------------------------------------------------------------------------- 00243 le_hashmap_Ref_t le_hashmap_Create 00244 ( 00245 const char* nameStr, 00246 size_t capacity, 00247 le_hashmap_HashFunc_t hashFunc, 00248 le_hashmap_EqualsFunc_t equalsFunc 00249 ); 00250 00251 //-------------------------------------------------------------------------------------------------- 00259 //-------------------------------------------------------------------------------------------------- 00260 00261 void* le_hashmap_Put 00262 ( 00263 le_hashmap_Ref_t mapRef, 00264 const void* keyPtr, 00265 const void* valuePtr 00266 ); 00267 00268 //-------------------------------------------------------------------------------------------------- 00275 //-------------------------------------------------------------------------------------------------- 00276 00277 void* le_hashmap_Get 00278 ( 00279 le_hashmap_Ref_t mapRef, 00280 const void* keyPtr 00281 ); 00282 00283 //-------------------------------------------------------------------------------------------------- 00290 //-------------------------------------------------------------------------------------------------- 00291 00292 void* le_hashmap_Remove 00293 ( 00294 le_hashmap_Ref_t mapRef, 00295 const void* keyPtr 00296 ); 00297 00298 //-------------------------------------------------------------------------------------------------- 00305 //-------------------------------------------------------------------------------------------------- 00306 00307 bool le_hashmap_isEmpty 00308 ( 00309 le_hashmap_Ref_t mapRef 00310 ); 00311 00312 //-------------------------------------------------------------------------------------------------- 00319 //-------------------------------------------------------------------------------------------------- 00320 00321 size_t le_hashmap_Size 00322 ( 00323 le_hashmap_Ref_t mapRef 00324 ); 00325 00326 //-------------------------------------------------------------------------------------------------- 00333 //-------------------------------------------------------------------------------------------------- 00334 00335 bool le_hashmap_ContainsKey 00336 ( 00337 le_hashmap_Ref_t mapRef, 00338 const void* keyPtr 00339 ); 00340 00341 //-------------------------------------------------------------------------------------------------- 00348 //-------------------------------------------------------------------------------------------------- 00349 00350 void le_hashmap_RemoveAll 00351 ( 00352 le_hashmap_Ref_t mapRef 00353 ); 00354 00355 //-------------------------------------------------------------------------------------------------- 00363 //-------------------------------------------------------------------------------------------------- 00364 void le_hashmap_ForEach 00365 ( 00366 le_hashmap_Ref_t mapRef, 00367 le_hashmap_ForEachHandler_t forEachFn, 00368 void* contextPtr 00369 ); 00370 00371 //-------------------------------------------------------------------------------------------------- 00384 //-------------------------------------------------------------------------------------------------- 00385 le_hashmap_It_Ref_t le_hashmap_GetIterator 00386 ( 00387 le_hashmap_Ref_t mapRef 00388 ); 00389 00390 //-------------------------------------------------------------------------------------------------- 00401 //-------------------------------------------------------------------------------------------------- 00402 le_result_t le_hashmap_NextNode 00403 ( 00404 le_hashmap_It_Ref_t iteratorRef 00405 ); 00406 00407 //-------------------------------------------------------------------------------------------------- 00416 //-------------------------------------------------------------------------------------------------- 00417 void const * le_hashmap_GetKey 00418 ( 00419 le_hashmap_It_Ref_t iteratorRef 00420 ); 00421 00422 //-------------------------------------------------------------------------------------------------- 00431 //-------------------------------------------------------------------------------------------------- 00432 void const * le_hashmap_GetValue 00433 ( 00434 le_hashmap_It_Ref_t iteratorRef 00435 ); 00436 00437 //-------------------------------------------------------------------------------------------------- 00449 //-------------------------------------------------------------------------------------------------- 00450 le_result_t le_hashmap_GetFirstNode 00451 ( 00452 le_hashmap_Ref_t mapRef, 00453 void **firstKeyPtr, 00454 void **firstValuePtr 00455 ); 00456 00457 //-------------------------------------------------------------------------------------------------- 00470 //-------------------------------------------------------------------------------------------------- 00471 le_result_t le_hashmap_GetNodeAfter 00472 ( 00473 le_hashmap_Ref_t mapRef, 00474 const void* keyPtr, 00475 void **nextKeyPtr, 00476 void **nextValuePtr 00477 ); 00478 00479 00480 //-------------------------------------------------------------------------------------------------- 00488 //-------------------------------------------------------------------------------------------------- 00489 00490 size_t le_hashmap_CountCollisions 00491 ( 00492 le_hashmap_Ref_t mapRef 00493 ); 00494 00495 //-------------------------------------------------------------------------------------------------- 00503 //-------------------------------------------------------------------------------------------------- 00504 00505 size_t le_hashmap_HashString 00506 ( 00507 const void* stringToHashPtr 00508 ); 00509 00510 //-------------------------------------------------------------------------------------------------- 00518 //-------------------------------------------------------------------------------------------------- 00519 00520 bool le_hashmap_EqualsString 00521 ( 00522 const void* firstStringPtr, 00523 const void* secondStringPtr 00524 ); 00525 00526 //-------------------------------------------------------------------------------------------------- 00534 //-------------------------------------------------------------------------------------------------- 00535 00536 size_t le_hashmap_HashUInt32 00537 ( 00538 const void* intToHashPtr 00539 ); 00540 00541 //-------------------------------------------------------------------------------------------------- 00549 //-------------------------------------------------------------------------------------------------- 00550 00551 bool le_hashmap_EqualsUInt32 00552 ( 00553 const void* firstIntPtr, 00554 const void* secondIntPtr 00555 ); 00556 00557 //-------------------------------------------------------------------------------------------------- 00565 //-------------------------------------------------------------------------------------------------- 00566 00567 size_t le_hashmap_HashVoidPointer 00568 ( 00569 const void* voidToHashPtr 00570 ); 00571 00572 //-------------------------------------------------------------------------------------------------- 00580 //-------------------------------------------------------------------------------------------------- 00581 00582 bool le_hashmap_EqualsVoidPointer 00583 ( 00584 const void* firstVoidPtr, 00585 const void* secondVoidPtr 00586 ); 00587 00588 00589 00590 //-------------------------------------------------------------------------------------------------- 00597 //-------------------------------------------------------------------------------------------------- 00598 void le_hashmap_MakeTraceable 00599 ( 00600 le_hashmap_Ref_t mapRef 00601 ); 00602 00603 00604 //-------------------------------------------------------------------------------------------------- 00608 //-------------------------------------------------------------------------------------------------- 00609 void le_hashmap_EnableTrace 00610 ( 00611 le_hashmap_Ref_t mapRef 00612 ); 00613 00614 00615 #endif /* LEGATO_HASHMAP_INCLUDE_GUARD */