Skip to content

Instantly share code, notes, and snippets.

@ayende
Last active June 11, 2020 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayende/c3c0208e86a1fceb6c51ef8df8c49f15 to your computer and use it in GitHub Desktop.
Save ayende/c3c0208e86a1fceb6c51ef8df8c49f15 to your computer and use it in GitHub Desktop.
struct range_finder {
// input
uint64_t *bitmap;
size_t bitmap_size;
size_t size_required;
size_t index;
// output
size_t size_available;
size_t selected_position;
// the current word we are working on
uint64_t current;
// state
uint64_t current_set_bit;
uint64_t previous_set_bit;
};
static void init_range(uint64_t *bitmap, size_t bitmap_size,
size_t size_required,
struct range_finder *restrict range);
static bool find_next(struct range_finder *restrict range);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment