add tlist, aka treap list
commit5ae900836b260d094e1ce92172f3d5c9042be5db
authorrofl0r <rofl0r@users.noreply.github.com>
Fri, 7 Jun 2024 23:01:27 +0000 (7 23:01 +0000)
committerrofl0r <rofl0r@users.noreply.github.com>
Fri, 7 Jun 2024 23:22:43 +0000 (7 23:22 +0000)
tree25982033b0f5aee0ed14ed14395c01596df1d894
parent321e1ee5ab17e00d7e24b14e7beaaf4902b62479
add tlist, aka treap list

a list optimized for fast insertion and deletion at arbitrary positions,
while also being reasonably fast at indexing - all operations complete
roughly in O(log N).

while there may be other potentially faster algorithms to achieve these
properties, probably none can compete in compactness and simplicity of
the implementation, of which the core code is about 90 lines of C in this
case. the rest of the code provides a nice API around it, which should
be familiar to users of my dynamic array implementation known as sblist.
the version committed here is the bare minimum to provide the most
important features of a list, extra features like those currently
available in sblist like sorted insertion or binary search may be added
in the future. the header file tlist.h provides comments explaining the
functionality, and the included test file can probably serve as a good
usage example.

credits go to the author of the e-maxx.ru article describing the
possibility of using a treap as a list with implicit indices instead of
keys - as the typical use of a treap is as a key-value store, similar
to a hashtable.
include/tlist.h [new file with mode: 0644]
src/tlist/tlist.c [new file with mode: 0644]
tests/tlist_test.c [new file with mode: 0644]