1 %%%----------------------------------------------------------------------------
2 %%% Equivalent to stdlib's orddict, but with a pretty (IMO), uniform interface.
3 %%%----------------------------------------------------------------------------
6 -behavior(hope_dictionary).
30 %% ============================================================================
32 %% ============================================================================
40 case lists:keyfind(K, 1, T)
46 lists:keystore(K, 1, T, {K, V}).
51 % TODO: Eliminate the 2nd lookup.
55 Map2 = lift_map_into_list(Map1),
56 lists:foreach(Map2, T).
59 Map2 = lift_map_into_list(Map1),
63 Map2 = lift_map_into_list(Map1),
64 lists:filter(Map2, T).
66 fold(T, F1, Accumulator) ->
67 F2 = fun ({K, V}, Acc) -> F1(K, V, Acc) end,
68 lists:foldl(F2, T, Accumulator).
74 % TODO: Decide if validation is to be done here. Do so if yes.
78 %% ============================================================================
80 %% ============================================================================
82 lift_map_into_list(Map) ->
83 fun ({K, V}) -> {K, Map(K, V)} end.