Formatting

This commit is contained in:
Gregory Burd 2012-06-24 23:12:39 +05:30
parent 17cb87ca42
commit a50e8bdb0d

View file

@ -63,12 +63,13 @@ is_element(Key, B, [Idx | T]) ->
%% @doc Adds the key to the filter.
-spec add_element(term(), #bloom{}) -> #bloom{}.
add_element(Key, #bloom{keys=Keys, n=N, bitmap=Bitmap} = B) when Keys < N ->
add_element(Key, #bloom{keys=Keys, n=N, bitmap=Bitmap}=B)
when Keys < N ->
Idxs = calc_idxs(Key, B),
Bitmap0 = set_bits(Bitmap, Idxs),
case Bitmap0 == Bitmap of
true -> B#bloom{bitmap=Bitmap0}; % Don't increment key count for duplicates.
false -> B#bloom{bitmap=Bitmap0, keys=Keys+1}
false -> B#bloom{bitmap=Bitmap0, keys=Keys + 1}
end.
%% @internal
@ -82,11 +83,6 @@ set_bits(Bin, [Idx | Idxs]) ->
Byte0 = Byte bor Mask,
set_bits(<<Pre/binary, Byte0:8, Post/binary>>, Idxs).
%set_bits(Bin, [Idx | Idxs]) ->
% <<Pre:Idx/bitstring, _:1/bitstring, Post/bitstring>> = Bin,
% set_bits(<<Pre/bitstring, 1:1, Post/bitstring>>, Idxs).
%% @internal
%% @doc Find the optimal bitmap size and number of hashes.
%TODO -spec(non_neg_integer(), number()) -> non_neg_integer().