Generic types. More...
Go to the source code of this file.
Data Structures | |
struct | tommy_node_struct |
Data structure node. More... | |
Macros | |
#define | tommy_malloc malloc |
Generic malloc(), calloc(), realloc() and free() functions. More... | |
#define | TOMMY_KEY_BIT (sizeof(tommy_key_t) * 8) |
Bits into the tommy_key_t type. More... | |
Typedefs | |
typedef uint32_t | tommy_uint32_t |
Generic uint32_t type. More... | |
typedef uint64_t | tommy_uint64_t |
Generic uint64_t type. More... | |
typedef uintptr_t | tommy_uintptr_t |
Generic uintptr_t type. More... | |
typedef size_t | tommy_size_t |
Generic size_t type. More... | |
typedef ptrdiff_t | tommy_ptrdiff_t |
Generic ptrdiff_t type. More... | |
typedef int | tommy_bool_t |
Generic boolean type. More... | |
typedef tommy_uint32_t | tommy_uint_t |
Generic unsigned integer type. More... | |
typedef tommy_uint32_t | tommy_count_t |
Generic unsigned integer for counting objects. More... | |
typedef tommy_uint32_t | tommy_key_t |
Key type used in indexed data structures to store the key or the hash value. More... | |
typedef struct tommy_node_struct | tommy_node |
Data structure node. More... | |
typedef int | tommy_compare_func(const void *obj_a, const void *obj_b) |
Compare function for elements. More... | |
typedef int | tommy_search_func(const void *arg, const void *obj) |
Search function for elements. More... | |
typedef void | tommy_foreach_func(void *obj) |
Foreach function. More... | |
typedef void | tommy_foreach_arg_func(void *arg, void *obj) |
Foreach function with an argument. More... | |
Functions | |
tommy_uint_t | tommy_ilog2_u32 (tommy_uint32_t value) |
Bit scan reverse or integer log2. More... | |
tommy_uint_t | tommy_ctz_u32 (tommy_uint32_t value) |
Bit scan forward or trailing zero count. More... | |
tommy_uint32_t | tommy_roundup_pow2_u32 (tommy_uint32_t value) |
Rounds up to the next power of 2. More... | |
int | tommy_haszero_u32 (tommy_uint32_t value) |
Check if the specified word has a byte at 0. More... | |
Generic types.
#define tommy_malloc malloc |
Generic malloc(), calloc(), realloc() and free() functions.
Redefine them to what you need. By default they map to the C malloc(), calloc(), realloc() and free().
#define TOMMY_KEY_BIT (sizeof(tommy_key_t) * 8) |
Bits into the tommy_key_t type.
typedef uint32_t tommy_uint32_t |
Generic uint32_t type.
typedef uint64_t tommy_uint64_t |
Generic uint64_t type.
typedef uintptr_t tommy_uintptr_t |
Generic uintptr_t type.
typedef size_t tommy_size_t |
Generic size_t type.
typedef ptrdiff_t tommy_ptrdiff_t |
Generic ptrdiff_t type.
typedef int tommy_bool_t |
Generic boolean type.
typedef tommy_uint32_t tommy_uint_t |
Generic unsigned integer type.
It has no specific size, as is used to store only small values. To make the code more efficient, a full 32 bit integer is used.
typedef tommy_uint32_t tommy_count_t |
Generic unsigned integer for counting objects.
TommyDS doesn't support more than 2^32-1 objects.
typedef tommy_uint32_t tommy_key_t |
Key type used in indexed data structures to store the key or the hash value.
typedef struct tommy_node_struct tommy_node |
typedef int tommy_compare_func(const void *obj_a, const void *obj_b) |
Compare function for elements.
obj_a | Pointer to the first object to compare. |
obj_b | Pointer to the second object to compare. |
This function is like the C strcmp().
typedef int tommy_search_func(const void *arg, const void *obj) |
Search function for elements.
arg | Pointer to the value to search as passed at the search function. |
obj | Pointer to the object to compare to. |
The first argument is a pointer to the value to search exactly as it's passed at the search function called. The second argument is a pointer to the object inside the hashtable to compare.
The return value has to be 0 if the values are equal. != 0 if they are different.
typedef void tommy_foreach_func(void *obj) |
typedef void tommy_foreach_arg_func(void *arg, void *obj) |
Foreach function with an argument.
arg | Pointer to a generic argument. |
obj | Pointer to the object to iterate. |
tommy_uint_t tommy_ilog2_u32 | ( | tommy_uint32_t | value | ) |
Bit scan reverse or integer log2.
Return the bit index of the most significant 1 bit.
If no bit is set, the result is undefined. To force a return 0 in this case, you can use tommy_ilog2_u32(value | 1).
Other interesting ways for bitscan are at:
Bit Twiddling Hacks http://graphics.stanford.edu/~seander/bithacks.html
Chess Programming BitScan http://chessprogramming.wikispaces.com/BitScan
value | Value to scan. 0 is not allowed. |
tommy_uint_t tommy_ctz_u32 | ( | tommy_uint32_t | value | ) |
Bit scan forward or trailing zero count.
Return the bit index of the least significant 1 bit.
If no bit is set, the result is undefined.
value | Value to scan. 0 is not allowed. |
tommy_uint32_t tommy_roundup_pow2_u32 | ( | tommy_uint32_t | value | ) |
Rounds up to the next power of 2.
For the value 0, the result is undefined.
int tommy_haszero_u32 | ( | tommy_uint32_t | value | ) |
Check if the specified word has a byte at 0.