minor whitespace cleanup

Signed-off-by: Jordan Wilberding <diginux@gmail.com>
This commit is contained in:
Eric Merritt 2012-09-04 20:32:39 -05:00
parent cf8cad00df
commit a2672cafb1
3 changed files with 34 additions and 34 deletions

View file

@ -47,12 +47,12 @@ has_key(Key, {ec_assoc_list, Data}) ->
lists:keymember(Key, 1, Data). lists:keymember(Key, 1, Data).
-spec get(ec_dictionary:key(K), Object::dictionary(K, V)) -> -spec get(ec_dictionary:key(K), Object::dictionary(K, V)) ->
ec_dictionary:value(V). ec_dictionary:value(V).
get(Key, {ec_assoc_list, Data}) -> get(Key, {ec_assoc_list, Data}) ->
case lists:keyfind(Key, 1, Data) of case lists:keyfind(Key, 1, Data) of
{Key, Value} -> {Key, Value} ->
Value; Value;
false -> false ->
throw(not_found) throw(not_found)
end. end.
@ -64,19 +64,19 @@ get(Key, Default, {ec_assoc_list, Data}) ->
case lists:keyfind(Key, 1, Data) of case lists:keyfind(Key, 1, Data) of
{Key, Value} -> {Key, Value} ->
Value; Value;
false -> false ->
Default Default
end. end.
-spec add(ec_dictionary:key(K), ec_dictionary:value(V), -spec add(ec_dictionary:key(K), ec_dictionary:value(V),
Object::dictionary(K, V)) -> Object::dictionary(K, V)) ->
dictionary(K, V). dictionary(K, V).
add(Key, Value, {ec_assoc_list, _Data}=Dict) -> add(Key, Value, {ec_assoc_list, _Data}=Dict) ->
{ec_assoc_list, Rest} = remove(Key,Dict), {ec_assoc_list, Rest} = remove(Key,Dict),
{ec_assoc_list, [{Key, Value} | Rest ]}. {ec_assoc_list, [{Key, Value} | Rest ]}.
-spec remove(ec_dictionary:key(K), Object::dictionary(K, _V)) -> -spec remove(ec_dictionary:key(K), Object::dictionary(K, _V)) ->
dictionary(K, _V). dictionary(K, _V).
remove(Key, {ec_assoc_list, Data}) -> remove(Key, {ec_assoc_list, Data}) ->
{ec_assoc_list, lists:keydelete(Key, 1, Data)}. {ec_assoc_list, lists:keydelete(Key, 1, Data)}.
@ -91,15 +91,15 @@ size({ec_assoc_list, Data}) ->
-spec to_list(dictionary(K, V)) -> [{ec_dictionary:key(K), -spec to_list(dictionary(K, V)) -> [{ec_dictionary:key(K),
ec_dictionary:value(V)}]. ec_dictionary:value(V)}].
to_list({ec_assoc_list, Data}) -> to_list({ec_assoc_list, Data}) ->
Data. Data.
-spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) -> -spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) ->
dictionary(K, V). dictionary(K, V).
from_list(List) when is_list(List) -> from_list(List) when is_list(List) ->
{ec_assoc_list, List}. {ec_assoc_list, List}.
-spec keys(dictionary(K, _V)) -> [ec_dictionary:key(K)]. -spec keys(dictionary(K, _V)) -> [ec_dictionary:key(K)].
keys({ec_assoc_list, Data}) -> keys({ec_assoc_list, Data}) ->
lists:map(fun({Key, _Value}) -> lists:map(fun({Key, _Value}) ->
Key Key
end, Data). end, Data).

View file

@ -48,59 +48,59 @@ has_key(Key, Data) ->
orddict:is_key(Key, Data). orddict:is_key(Key, Data).
-spec get(ec_dictionary:key(K), Object::dictionary(K, V)) -> -spec get(ec_dictionary:key(K), Object::dictionary(K, V)) ->
ec_dictionary:value(V). ec_dictionary:value(V).
get(Key, Data) -> get(Key, Data) ->
case orddict:find(Key, Data) of case orddict:find(Key, Data) of
{ok, Value} -> {ok, Value} ->
Value; Value;
error -> error ->
throw(not_found) throw(not_found)
end. end.
-spec get(ec_dictionary:key(K), -spec get(ec_dictionary:key(K),
Default::ec_dictionary:value(V), Default::ec_dictionary:value(V),
Object::dictionary(K, V)) -> Object::dictionary(K, V)) ->
ec_dictionary:value(V). ec_dictionary:value(V).
get(Key, Default, Data) -> get(Key, Default, Data) ->
case orddict:find(Key, Data) of case orddict:find(Key, Data) of
{ok, Value} -> {ok, Value} ->
Value; Value;
error -> error ->
Default Default
end. end.
-spec add(ec_dictionary:key(K), ec_dictionary:value(V), -spec add(ec_dictionary:key(K), ec_dictionary:value(V),
Object::dictionary(K, V)) -> Object::dictionary(K, V)) ->
dictionary(K, V). dictionary(K, V).
add(Key, Value, Data) -> add(Key, Value, Data) ->
orddict:store(Key, Value, Data). orddict:store(Key, Value, Data).
-spec remove(ec_dictionary:key(K), Object::dictionary(K, V)) -> -spec remove(ec_dictionary:key(K), Object::dictionary(K, V)) ->
dictionary(K, V). dictionary(K, V).
remove(Key, Data) -> remove(Key, Data) ->
orddict:erase(Key, Data). orddict:erase(Key, Data).
-spec has_value(ec_dictionary:value(V), Object::dictionary(_K, V)) -> boolean(). -spec has_value(ec_dictionary:value(V), Object::dictionary(_K, V)) -> boolean().
has_value(Value, Data) -> has_value(Value, Data) ->
orddict:fold(fun(_, NValue, _) when NValue == Value -> orddict:fold(fun(_, NValue, _) when NValue == Value ->
true; true;
(_, _, Acc) -> (_, _, Acc) ->
Acc Acc
end, end,
false, false,
Data). Data).
-spec size(Object::dictionary(_K, _V)) -> non_neg_integer(). -spec size(Object::dictionary(_K, _V)) -> non_neg_integer().
size(Data) -> size(Data) ->
orddict:size(Data). orddict:size(Data).
-spec to_list(dictionary(K, V)) -> -spec to_list(dictionary(K, V)) ->
[{ec_dictionary:key(K), ec_dictionary:value(V)}]. [{ec_dictionary:key(K), ec_dictionary:value(V)}].
to_list(Data) -> to_list(Data) ->
orddict:to_list(Data). orddict:to_list(Data).
-spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) -> -spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) ->
dictionary(K, V). dictionary(K, V).
from_list(List) when is_list(List) -> from_list(List) when is_list(List) ->
orddict:from_list(List). orddict:from_list(List).

View file

@ -139,12 +139,12 @@ size(T) ->
size1(T). size1(T).
-spec to_list(dictionary(K, V)) -> -spec to_list(dictionary(K, V)) ->
[{ec_dictionary:key(K), ec_dictionary:value(V)}]. [{ec_dictionary:key(K), ec_dictionary:value(V)}].
to_list(T) -> to_list(T) ->
to_list(T, []). to_list(T, []).
-spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) -> -spec from_list([{ec_dictionary:key(K), ec_dictionary:value(V)}]) ->
dictionary(K, V). dictionary(K, V).
from_list(L) -> from_list(L) ->
lists:foldl(fun ({K, V}, D) -> lists:foldl(fun ({K, V}, D) ->
add(K, V, D) add(K, V, D)
@ -159,7 +159,7 @@ keys(Dict) ->
%%% Enternal functions %%% Enternal functions
%%%=================================================================== %%%===================================================================
-spec keys(dictionary(K, _V), [ec_dictionary:key(K)]) -> -spec keys(dictionary(K, _V), [ec_dictionary:key(K)]) ->
[ec_dictionary:key(K)]. [ec_dictionary:key(K)].
keys(empty, Tail) -> keys(empty, Tail) ->
Tail; Tail;
keys({_, L, K, _, R}, Tail) -> keys({_, L, K, _, R}, Tail) ->
@ -167,7 +167,7 @@ keys({_, L, K, _, R}, Tail) ->
-spec erase_aux(ec_dictionary:key(K), dictionary(K, V)) -> -spec erase_aux(ec_dictionary:key(K), dictionary(K, V)) ->
{dictionary(K, V), boolean()}. {dictionary(K, V), boolean()}.
erase_aux(_, empty) -> erase_aux(_, empty) ->
{empty, false}; {empty, false};
erase_aux(K, {b, A, Xk, Xv, B}) -> erase_aux(K, {b, A, Xk, Xv, B}) ->
@ -228,7 +228,7 @@ erase_aux(K, {r, A, Xk, Xv, B}) ->
end. end.
-spec erase_min(dictionary(K, V)) -> -spec erase_min(dictionary(K, V)) ->
{dictionary(K, V), {ec_dictionary:key(K), ec_dictionary:value(V)}, boolean()}. {dictionary(K, V), {ec_dictionary:key(K), ec_dictionary:value(V)}, boolean()}.
erase_min({b, empty, Xk, Xv, empty}) -> erase_min({b, empty, Xk, Xv, empty}) ->
{empty, {Xk, Xv}, true}; {empty, {Xk, Xv}, true};
erase_min({b, empty, Xk, Xv, {r, A, Yk, Yv, B}}) -> erase_min({b, empty, Xk, Xv, {r, A, Yk, Yv, B}}) ->
@ -240,15 +240,15 @@ erase_min({r, empty, Xk, Xv, A}) ->
erase_min({b, A, Xk, Xv, B}) -> erase_min({b, A, Xk, Xv, B}) ->
{A1, Min, Dec} = erase_min(A), {A1, Min, Dec} = erase_min(A),
if Dec -> if Dec ->
{T, Dec1} = unbalright(b, A1, Xk, Xv, B), {T, Dec1} = unbalright(b, A1, Xk, Xv, B),
{T, Min, Dec1}; {T, Min, Dec1};
true -> {{b, A1, Xk, Xv, B}, Min, false} true -> {{b, A1, Xk, Xv, B}, Min, false}
end; end;
erase_min({r, A, Xk, Xv, B}) -> erase_min({r, A, Xk, Xv, B}) ->
{A1, Min, Dec} = erase_min(A), {A1, Min, Dec} = erase_min(A),
if Dec -> if Dec ->
{T, Dec1} = unbalright(r, A1, Xk, Xv, B), {T, Dec1} = unbalright(r, A1, Xk, Xv, B),
{T, Min, Dec1}; {T, Min, Dec1};
true -> {{r, A1, Xk, Xv, B}, Min, false} true -> {{r, A1, Xk, Xv, B}, Min, false}
end. end.
@ -299,7 +299,7 @@ to_list({_, A, Xk, Xv, B}, List) ->
-spec lbalance(color(), dictionary(K, V), -spec lbalance(color(), dictionary(K, V),
ec_dictionary:key(K), ec_dictionary:value(V), ec_dictionary:key(K), ec_dictionary:value(V),
dictionary(K, V)) -> dictionary(K, V)) ->
dictionary(K, V). dictionary(K, V).
lbalance(b, {r, {r, A, Xk, Xv, B}, Yk, Yv, C}, Zk, Zv, lbalance(b, {r, {r, A, Xk, Xv, B}, Yk, Yv, C}, Zk, Zv,
D) -> D) ->
{r, {b, A, Xk, Xv, B}, Yk, Yv, {b, C, Zk, Zv, D}}; {r, {b, A, Xk, Xv, B}, Yk, Yv, {b, C, Zk, Zv, D}};
@ -311,7 +311,7 @@ lbalance(C, A, Xk, Xv, B) -> {C, A, Xk, Xv, B}.
-spec rbalance(color(), dictionary(K, V), -spec rbalance(color(), dictionary(K, V),
ec_dictionary:key(K), ec_dictionary:value(V), ec_dictionary:key(K), ec_dictionary:value(V),
dictionary(K, V)) -> dictionary(K, V)) ->
dictionary(K, V). dictionary(K, V).
rbalance(b, A, Xk, Xv, rbalance(b, A, Xk, Xv,
{r, {r, B, Yk, Yv, C}, Zk, Zv, D}) -> {r, {r, B, Yk, Yv, C}, Zk, Zv, D}) ->
{r, {b, A, Xk, Xv, B}, Yk, Yv, {b, C, Zk, Zv, D}}; {r, {b, A, Xk, Xv, B}, Yk, Yv, {b, C, Zk, Zv, D}};