 
   """
   @spec size(t) :: non_neg_integer
-  def size(%MapSet{data: map}) do
+  def size(%MapSet{map: map}) do
     map_size(map)
   end
 


  """
  @spec union(t(val1), t(val2)) :: t(val1 | val2) when val1: value, val2: value
  def union(%MapSet{data: map1}, %MapSet{data: map2}) do
    %MapSet{data: Map.merge(map1, map2)}
  end

  defp order_by_size(map1, map2) when map_size(map1) > map_size(map2), do: {map2, map1}

  # If the first set is less than twice the size of the second map,
  # it is fastest to re-accumulate items in the first set that are not
  # present in the second set.
  def difference(%MapSet{map: map1}, %MapSet{map: map2})
      when map_size(map1) < map_size(map2) * 2 do
    map =
      map1
      |> Map.keys
      |> filter_not_in(map2)

    %MapSet{map: map}
  end

  # If the second set is less than half the size of the first set, it's fastest
  # to simply iterate through each item in the second set, deleting them from
  # the first set.
  def difference(%MapSet{map: map1}, %MapSet{map: map2}) do
    %MapSet{map: Map.drop(map1, Map.keys(map2))}
  end

  defp filter_not_in(keys, map2, acc \\ [])
  defp filter_not_in([], _map2, acc), do: :maps.from_list(acc)
  defp filter_not_in([key | rest], map2, acc) do
    acc =
      if Map.has_key?(map2, key) do
        acc
      else
        [{key, []} | acc]
      end
    filter_not_in(rest, map2, acc)
  end

