Permalink
Browse files

fix argument order of info/2 to be backwards compatible with ets

  • Loading branch information...
1 parent 6f763ed commit dc1c1a5b61a052cb90927aa0874cc65c0a295f26 Richard Carlsson committed Oct 9, 2011
Showing with 12 additions and 12 deletions.
  1. +6 −6 lib/stdlib/src/dict.erl
  2. +6 −6 lib/stdlib/src/orddict.erl
View
@@ -329,19 +329,19 @@ is_empty(Dict) -> size(Dict) =< 0.
info(Dict) ->
Items = [size,type],
- [info(Item, Dict) || Item <- Items].
+ [info(Dict, Item) || Item <- Items].
--spec info(InfoTag, Dict) -> Value when
+-spec info(Dict, InfoTag) -> Value when
+ InfoTag :: 'size' | 'type',
Dict :: dict(),
- InfoTag :: 'size' | 'type' | atom(),
Value :: term().
%% @doc Get information about a dictionary. This is a constant time
%% operation.
-info(size, Dict) -> size(Dict);
-info(type, #dict{}) -> set;
-info(type, ?gb(_,_)) -> ordered_set;
+info(Dict, size) -> size(Dict);
+info(#dict{}, type) -> set;
+info(?gb(_,_), type) -> ordered_set;
info(_, _) -> undefined.
-spec values(Dict) -> [Val] when
View
@@ -163,26 +163,26 @@ is_empty(Dict) -> Dict =:= [].
-spec info(Orddict) -> [InfoTuple] when
Orddict :: orddict(),
InfoTuple :: {InfoTag, Value},
- InfoTag :: 'size' | 'type',
+ InfoTag :: 'size',
Value :: term().
%% @doc Get information about a dictionary. Returns a list of tagged tuples
%% corresponding to individual calls to {@link info/2} for all allowed tags.
%% Note that this takes time proportional to the number of elements.
info(Dict) ->
- Items = [size,type],
- [info(Item, Dict) || Item <- Items].
+ Items = [size],
+ [info(Dict, Item) || Item <- Items].
--spec info(InfoTag, Orddict) -> Value when
+-spec info(Orddict, InfoTag) -> Value when
+ InfoTag :: 'size',
Orddict :: orddict(),
- InfoTag :: 'size' | atom(),
Value :: term().
%% @doc Get information about a dictionary. Note that getting the size of an
%% orddict takes time proportional to the number of elements.
-info(size, Dict) -> size(Dict);
+info(Dict, size) -> size(Dict);
info(_, _) -> undefined.
-spec values(Orddict) -> [Val] when

0 comments on commit dc1c1a5

Please sign in to comment.