Last active
January 6, 2016 03:12
-
-
Save Vagabond/479602ba9bd3a59155f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hashmap_delete_pre(S) -> | |
S#state.hashmap /= undefined. | |
hashmap_delete_args(S = #state{map=Map}) when length(Map) > 0 -> | |
[S#state.hashmap, | |
eqc_gen:oneof([eqc_gen:elements(element(1, lists:unzip(S#state.map))), | |
?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)])]; | |
hashmap_delete_args(S) -> | |
[S#state.hashmap, ?SUCHTHAT(X1, eqc_gen:list(eqc_gen:char()), length(X1) > 0)]. | |
hashmap_delete(Hashmap, Key) -> | |
KeyStr = eqc_c:create_string(Key), | |
R = hashmap:hashmap_del(Hashmap, KeyStr, length(Key)), | |
eqc_c:free(KeyStr), | |
R. | |
hashmap_delete_post(S, [_, Key], R) -> | |
%% check the return code against whether the key was in the map | |
case lists:keyfind(Key, 1, S#state.map) of | |
{Key, _} -> | |
R == 0; | |
false -> | |
R == 1 | |
end. | |
hashmap_delete_next(S, _R, [_, Key]) -> | |
S#state{map=lists:keydelete(Key, 1, S#state.map)}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment