diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-25 19:04:38 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-03-25 19:04:38 -0400 |
| commit | 1ca38045a0be0b6121e7a1b75dc80dde5a955898 (patch) | |
| tree | 2d026f507dd239d04491f2d216132b9400dca71f /pk.h.in | |
| parent | 5159f9717b20f5d2b63b57cea883ee9741a3cf24 (diff) | |
pkbktarr: created + bump pk.h version to 0.4.3
Diffstat (limited to 'pk.h.in')
| -rw-r--r-- | pk.h.in | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -213,6 +213,44 @@ * 2 times for each uuidv7 to fill 74 bits with random data (with an XOR for the * remaining 10 bits). * +******************************************************************************** +* pkbktarr.h: define PK_IMPL_BKTARR before including pk.h to enable ad-hoc. +* +* Provides a struct for bucketed data allocation. +* +* Maximum (default) bucket limits are as follows: +* buckets: 0xFFFFFF (16777215) +* items/bucket: 0x40 (64) +* +* Note that you may specify separate `pk_membucket`s for the the struct's +* arrays `bucketed_data` + `idx_unused`, and the actual bucketed array data +* found within `bucketed_data`. +* If the `pk_membucket` for "data" is exclusive to this struct, each bucket (and +* by extension, the data) will be contiguious in memory. +* +* Examples: +* ```c +* struct pk_bkt_arr_handle custom_limits; +* custom_limits.b = 8; +* custom_limits.i = 8; +* struct pk_bkt_arr arr; +* pk_bkt_arr_init( +* &arr, sizeof(int), alignof(int), custom_limits, bkt_buckets, bkt_data); +* struct pk_bkt_arr_handle h = pk_bkt_arr_new_handle(&arr); +* int **int_ptrs = (int**)arr.bucketed_data; +* int_ptrs[h.b][h.i] = 128; +* pk_bkt_arr_free_handle(&arr, h); +* pk_bkt_arr_teardown(&arr); +* ``` +* ```c++ +* // default limits, no pk_membucket +* struct pk_bkt_arr<int> arr(); +* struct pk_bkt_arr_handle h = pk_bkt_arr_new_handle(&arr); +* arr[h] = 128; +* pk_bkt_arr_free_handle(&arr, h); +* arr.~pk_bkt_arr<int>(); // manually call dtor for globals +* ``` +* *******************************************************************************/ #define PK_VERSION "@@PK_VERSION@@" @@ -239,4 +277,7 @@ # ifndef PK_IMPL_UUID # define PK_IMPL_UUID # endif +# ifndef PK_IMPL_BKTARR +# define PK_IMPL_BKTARR +# endif #endif |
