From 6e8f8a9c86240e987bbf333c18e74a345cf8e554 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Wed, 4 Jan 2017 17:19:27 +0000 Subject: [PATCH] Strip out extra stuff from skiplist --- src/leveled_skiplist.erl | 58 ---------------------------------------- 1 file changed, 58 deletions(-) diff --git a/src/leveled_skiplist.erl b/src/leveled_skiplist.erl index e8d8627..a5c3414 100644 --- a/src/leveled_skiplist.erl +++ b/src/leveled_skiplist.erl @@ -28,8 +28,6 @@ to_range/3, lookup/2, lookup/3, - key_above/2, - key_above_notequals/2, empty/0, empty/1, size/1 @@ -124,16 +122,6 @@ to_range(SkipList, Start, End) -> to_list(SkipList) -> to_list(element(2, SkipList), ?LIST_HEIGHT). -%% If a mark is found that matches the key, will return that mark -key_above(SkipList, Key) -> - TestFun = fun(Mark, K) -> Mark >= K end, - key_above(element(2, SkipList), Key, ?LIST_HEIGHT, TestFun). - -%% If a mark is found that matches the key, will return the next mark -key_above_notequals(SkipList, Key) -> - TestFun = fun(Mark, K) -> Mark > K end, - key_above(element(2, SkipList), Key, ?LIST_HEIGHT, TestFun). - empty() -> empty(false). @@ -329,37 +317,6 @@ sublist_above(SkipList, StartKey, Level, StartIncl) -> sublist_above(SL, StartKey, Level - 1, StartIncl) end. -key_above(SkipList, Key, 0, TestFun) -> - FindFun = fun({Mark, V}, Found) -> - case Found of - false -> - case TestFun(Mark, Key) of - true -> - {Mark, V}; - false -> - false - end; - _ -> - Found - end - end, - lists:foldl(FindFun, false, SkipList); -key_above(SkipList, Key, Level, TestFun) -> - FindFun = fun({Mark, SL}, Found) -> - case Found of - false -> - case TestFun(Mark, Key) of - true -> - key_above(SL, Key, Level - 1, TestFun); - false -> - false - end; - _ -> - Found - end - end, - lists:foldl(FindFun, false, SkipList). - empty(SkipList, 1) -> [{?INFINITY_KEY, SkipList}]; empty(SkipList, Level) -> @@ -658,21 +615,6 @@ skiplist_nolookup_test() -> KL), ?assertMatch(KLSorted, to_list(SkipList)). -skiplist_keybefore_test() -> - N = 128, - KL = generate_randomkeys(1, N, 1, N div 5), - SkipList = lists:foldl(fun({K, V}, Acc) -> - enter_nolookup(K, V, Acc) end, - empty(true), - KL), - KLSorted = lists:ukeysort(1, lists:reverse(KL)), - SW = os:timestamp(), - lists:foreach(fun({K, V}) -> - ?assertMatch({K, V}, key_above(SkipList, K)) end, - KLSorted), - io:format(user, "~nFinding self in keys above ~w microseconds for ~w finds~n", - [timer:now_diff(os:timestamp(), SW), N]). - skiplist_range_test() -> N = 150, KL = generate_randomkeys(1, N, 1, N div 5),