From 0149a73d15df1f80cb46752ec3829f48c38dd230 Mon Sep 17 00:00:00 2001
From: Lukas Larsson  This module contains functions for maps processing. An iterator representing the key value associations in a map. Created using  Consumed by  Returns a map  Returns a map  The call fails with a 
Example:
 > M = #{a => 2, b => 3, c=> 4, "a" => 1, "b" => 2, "c" => 4},
@@ -76,12 +92,16 @@
        
       
         Calls F(K, V, AccIn)  for every K   to value
-          V   association in Map   in
+          V   association in MapOrIter   in
           any order. Function fun F/3  must return a new
           accumulator, which is passed to the next successive call.
           This function returns the final value of the accumulator. The initial
           accumulator value Init   is returned if the map is
           empty.
+        The call fails with a {badmap,Map}  exception if
+          MapOrIter   is not a map or valid iterator,
+          or with badarg  if Fun   is not a
+          function of arity 3.
         Example:
         
 > Fun = fun(K,V,AccIn) when is_list(K) -> AccIn + V end,
@@ -168,6 +188,75 @@ false
        
     
 
+    
+       
+      Create a map iterator. 
+      
+        Returns a map iterator Iterator   that can
+          be used by maps:next/1  
+          to traverse the keys and values in a map. This call is equivalent
+          to calling maps:iterator/2  
+          with an empty map as the options.
+        The call fails with a {badmap,Map}  exception if
+          Map   is not a map.
+        Example:
+        
+> M = #{ a => 1, b => 2 }.
+#{a => 1,b => 2}
+> I = maps:iterator(M).
+[{a,1},{b,2}]
+> {K1, V1, I2} = maps:next(I).
+{a,1,[{b,2}]}
+> {K2, V2, I3} = maps:next(I2).
+{b,2,[]}
+> maps:next(I3).
+none
+       
+     
+
+    
+       
+      Create a map iterator. 
+      
+        Returns a map iterator Iterator   that can
+          be used by maps:next/1  
+          to traverse the keys and values in a map. The iterator will behave
+          according to the given Opts  .
+        
+          optimize 
+          - 
+            Configures whether the iterator should be optimized for 
speed 
+            or for memory  consumption. Default is speed .
+           
+          ordered 
+          - 
+            Configures whether the iterator should return the key value
+            associations ordered on the keys according to erlang term order
+            or not. The default is 
false .
+           
+         
+        Both options can be configured at the same time.
+        The call fails with a {badmap,Map}  exception if
+          Map   is not a map.
+        Example:
+        
+> M = maps:from_list([{I,I} || I <- lists:seq(1,50)]).
+#{45 => 45,6 => 6,2 => 2,49 => 49,41 => 41,33 => 33,42 => 42,
+  43 => 43,10 => 10,9 => 9,19 => 19,14 => 14,5 => 5,18 => 18,
+  31 => 31,22 => 22,29 => 29,21 => 21,27 => 27,24 => 24,
+  47 => 47,40 => 40,30 => 30,23 => 23,28 => 28,46 => 46,
+  16 => 16,38 => 38,4 => 4,...}
+> MemoryIter = maps:iterator(M, #{ optimize => memory }), ok.
+ok
+> {K1, V1, _} = maps:next(MemoryIter), {K1, V1}.
+{46,46}
+> OrderedIter = maps:iterator(M, #{ ordered => true, optimize => memory }), ok.
+ok
+> {K2, V2, _} = maps:next(OrderedIter), {K2, V2}.
+{1,1}
+       
+     
+
     
        
        
@@ -188,12 +277,16 @@ false 
       Produces a new map 
Produces a new map 
The call fails with a 
Example:
 > Fun = fun(K,V1) when is_list(K) -> V1*2 end,
@@ -233,6 +326,35 @@ false
       Returns the next key-value association in
+          
+          If there are no more associations in the iterator,
+          
Example:
+
+> Map = #{a => 1, b => 2, c => 3}.
+#{a => 1,b => 2,c => 3}
+> Iter = maps:iterator(Map).
+[{a,1},{b,2},{c,3}]
+> {_, _, Iter1} = maps:next(Iter).
+{a,1,[{b,2},{c,3}]}
+> {_, _, Iter2} = maps:next(Iter1).
+{b,2,[{c,3}]}
+> {_, _, Iter3} = maps:next(Iter2).
+{c,3,[]}
+> maps:next(Iter3).
+none
+      An iterator representing the key value associations in a map.
-Created using 
Created using 
Consumed by  Returns a map iterator 
The call fails with a 
Example:
@@ -214,49 +213,6 @@ noneReturns a map iterator 
Both options can be configured at the same time.
-The call fails with a 
Example:
-
-> M = maps:from_list([{I,I} || I <- lists:seq(1,50)]).
-#{45 => 45,6 => 6,2 => 2,49 => 49,41 => 41,33 => 33,42 => 42,
-  43 => 43,10 => 10,9 => 9,19 => 19,14 => 14,5 => 5,18 => 18,
-  31 => 31,22 => 22,29 => 29,21 => 21,27 => 27,24 => 24,
-  47 => 47,40 => 40,30 => 30,23 => 23,28 => 28,46 => 46,
-  16 => 16,38 => 38,4 => 4,...}
-> MemoryIter = maps:iterator(M, #{ optimize => memory }), ok.
-ok
-> {K1, V1, _} = maps:next(MemoryIter), {K1, V1}.
-{46,46}
-> OrderedIter = maps:iterator(M, #{ ordered => true, optimize => memory }), ok.
-ok
-> {K2, V2, _} = maps:next(OrderedIter), {K2, V2}.
-{1,1}
-