@@ -41,6 +41,7 @@ defmodule MapSet do
41
41
@ opaque t ( value ) :: % __MODULE__ { map: % { optional ( value ) => [ ] } }
42
42
@ type t :: t ( term )
43
43
44
+ # TODO: Remove version key on Elixir 2.0
44
45
defstruct map: % { } , version: 2
45
46
46
47
@ doc """
@@ -169,11 +170,8 @@ defmodule MapSet do
169
170
170
171
defp filter_not_in ( [ key | rest ] , map2 , acc ) do
171
172
case map2 do
172
- % { ^ key => _ } ->
173
- filter_not_in ( rest , map2 , acc )
174
-
175
- _ ->
176
- filter_not_in ( rest , map2 , [ { key , @ dummy_value } | acc ] )
173
+ % { ^ key => _ } -> filter_not_in ( rest , map2 , acc )
174
+ _ -> filter_not_in ( rest , map2 , [ { key , @ dummy_value } | acc ] )
177
175
end
178
176
end
179
177
@@ -384,14 +382,14 @@ defmodule MapSet do
384
382
end
385
383
386
384
defimpl Collectable do
387
- def into ( original ) do
385
+ def into ( map_set ) do
388
386
fun = fn
389
- map_set , { :cont , x } -> MapSet . put ( map_set , x )
390
- map_set , :done -> map_set
387
+ list , { :cont , x } -> [ { x , [ ] } | list ]
388
+ list , :done -> % { map_set | map: Map . merge ( map_set . map , Map . new ( list ) ) }
391
389
_ , :halt -> :ok
392
390
end
393
391
394
- { original , fun }
392
+ { [ ] , fun }
395
393
end
396
394
end
397
395
0 commit comments