X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=map%2Fskiplist.c;h=49ef21b3d32bcfe43c0e38cfdad883be1994eda5;hp=a0e9c60769a2ce5847471fbbaf9fc6894c8828db;hb=f7a1c10d18dcc2654d0c9b1f5ffc9f4ec9b23776;hpb=d26bac75802a324ed98c8d3d88cfb9eb87b3b35a diff --git a/map/skiplist.c b/map/skiplist.c index a0e9c60..49ef21b 100644 --- a/map/skiplist.c +++ b/map/skiplist.c @@ -22,7 +22,6 @@ #include "common.h" #include "runtime.h" -#include "mlocal.h" #include "skiplist.h" #include "mem.h" @@ -41,13 +40,6 @@ struct sl { const datatype_t *key_type; }; -static const map_impl_t sl_map_impl = { - (map_alloc_t)sl_alloc, (map_cas_t)sl_cas, (map_get_t)sl_lookup, (map_remove_t)sl_remove, - (map_count_t)sl_count, (map_print_t)sl_print, (map_free_t)sl_free -}; - -const map_impl_t *MAP_TYPE_SKIPLIST = &sl_map_impl; - static int random_level (void) { unsigned r = nbd_rand(); if (r & 1) @@ -239,6 +231,17 @@ uint64_t sl_lookup (skiplist_t *sl, void *key) { return DOES_NOT_EXIST; } +void *sl_min_key (skiplist_t *sl) { + node_t *item = sl->head->next[0]; + while (item != NULL) { + node_t *next = item->next[0]; + if (!IS_TAGGED(next)) + return item->key; + item = (node_t *)STRIP_TAG(next); + } + return DOES_NOT_EXIST; +} + uint64_t sl_cas (skiplist_t *sl, void *key, uint64_t expectation, uint64_t new_val) { TRACE("s1", "sl_cas: key %p skiplist %p", key, sl); TRACE("s1", "sl_cas: expectation %p new value %p", expectation, new_val);