silentbicycle / skiparray

unrolled skip list library for C
ISC License
21 stars 2 forks source link

Bulk insertion #1

Closed silentbicycle closed 5 years ago

silentbicycle commented 5 years ago

Building a skiparray by adding a bunch of nodes individually is more expensive than it needs to be, due to redundant searching for where to put the pair - as long as the pairs are already sorted by key, this could be very cheap.

Create an opaque struct skiparray_builder struct and associated functions that allocate one (with config, including a flag to skip ordering checks), append a key/value pair, and finish building and convert to a struct skiparray. This interface should be incremental, rather than taking an array, so it can be done lazily inside of other iteration.

It'd also be good to be able to do bulk insertion into an existing skiparray, but that will be a separate interface.