diff options
author | Magnus Henoch <[email protected]> | 2013-09-04 14:08:34 +0100 |
---|---|---|
committer | Magnus Henoch <[email protected]> | 2013-09-13 10:44:23 +0100 |
commit | 0e4b0ae7ce57117a561f70fa51026d85b4702aaa (patch) | |
tree | 4a0aba55aaeef71d6f2abed3b8aec50cd0018c6a /lib/stdlib/test/dict_SUITE.erl | |
parent | 5b56a49d15d10ad4a35dbc8b2a4b01486f1d5294 (diff) | |
download | otp-0e4b0ae7ce57117a561f70fa51026d85b4702aaa.tar.gz otp-0e4b0ae7ce57117a561f70fa51026d85b4702aaa.tar.bz2 otp-0e4b0ae7ce57117a561f70fa51026d85b4702aaa.zip |
Add dict:is_empty/1 and orddict:is_empty/1
dict:size/1 runs in constant time, but orddict:size/1 does not. With
this change, the two modules stay API compatible and gain a
constant-time function for checking whether a dictionary is empty.
Diffstat (limited to 'lib/stdlib/test/dict_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/dict_SUITE.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/stdlib/test/dict_SUITE.erl b/lib/stdlib/test/dict_SUITE.erl index 0223240479..69814e12ce 100644 --- a/lib/stdlib/test/dict_SUITE.erl +++ b/lib/stdlib/test/dict_SUITE.erl @@ -17,7 +17,7 @@ %% %CopyrightEnd% %% -%% This module tests the ordsets, sets, and gb_sets modules. +%% This module tests the orddict, dict, and gb_trees modules. %% -module(dict_SUITE). @@ -68,6 +68,7 @@ create_1(M) -> D0 = M(empty, []), [] = M(to_list, D0), 0 = M(size, D0), + true = M(is_empty, D0), D0. store(Config) when is_list(Config) -> @@ -81,6 +82,14 @@ store_1(List, M) -> D1 = foldl(fun({K,V}, Dict) -> M(enter, {K,V,Dict}) end, M(empty, []), List), true = M(equal, {D0,D1}), + case List of + [] -> + true = M(is_empty, D0), + true = M(is_empty, D1); + [_|_] -> + false = M(is_empty, D0), + false = M(is_empty, D1) + end, D0. %%% |