Strip out extra stuff from skiplist
This commit is contained in:
parent
f1d26e279c
commit
6e8f8a9c86
1 changed files with 0 additions and 58 deletions
|
@ -28,8 +28,6 @@
|
||||||
to_range/3,
|
to_range/3,
|
||||||
lookup/2,
|
lookup/2,
|
||||||
lookup/3,
|
lookup/3,
|
||||||
key_above/2,
|
|
||||||
key_above_notequals/2,
|
|
||||||
empty/0,
|
empty/0,
|
||||||
empty/1,
|
empty/1,
|
||||||
size/1
|
size/1
|
||||||
|
@ -124,16 +122,6 @@ to_range(SkipList, Start, End) ->
|
||||||
to_list(SkipList) ->
|
to_list(SkipList) ->
|
||||||
to_list(element(2, SkipList), ?LIST_HEIGHT).
|
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() ->
|
||||||
empty(false).
|
empty(false).
|
||||||
|
|
||||||
|
@ -329,37 +317,6 @@ sublist_above(SkipList, StartKey, Level, StartIncl) ->
|
||||||
sublist_above(SL, StartKey, Level - 1, StartIncl)
|
sublist_above(SL, StartKey, Level - 1, StartIncl)
|
||||||
end.
|
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) ->
|
empty(SkipList, 1) ->
|
||||||
[{?INFINITY_KEY, SkipList}];
|
[{?INFINITY_KEY, SkipList}];
|
||||||
empty(SkipList, Level) ->
|
empty(SkipList, Level) ->
|
||||||
|
@ -658,21 +615,6 @@ skiplist_nolookup_test() ->
|
||||||
KL),
|
KL),
|
||||||
?assertMatch(KLSorted, to_list(SkipList)).
|
?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() ->
|
skiplist_range_test() ->
|
||||||
N = 150,
|
N = 150,
|
||||||
KL = generate_randomkeys(1, N, 1, N div 5),
|
KL = generate_randomkeys(1, N, 1, N div 5),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue