Skip to content

Commit b1915b1

Browse files
author
José Valim
committed
Convert HashSet to use the new trie implementation
1 parent 5991eb0 commit b1915b1

File tree

6 files changed

+254
-501
lines changed

6 files changed

+254
-501
lines changed

lib/elixir/lib/dict.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ defmodule Dict do
4545
@type t :: tuple | list
4646

4747
defcallback new :: t
48-
defcallback new(Keyword.t) :: t
49-
defcallback new(Keyword.t, (any -> { key, value })) :: t
48+
defcallback new(Enum.t) :: t
49+
defcallback new(Enum.t, (any -> { key, value })) :: t
5050
defcallback delete(t, key) :: t
5151
defcallback drop(t, [key]) :: t
5252
defcallback empty(t) :: t

lib/elixir/lib/hash_dict.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ defmodule HashDict do
4040
#=> #HashDict<[a: 2, b: 1]>
4141
4242
"""
43-
@spec new(list({key :: term, value :: term})) :: Dict.t
44-
def new(pairs) do
45-
Enum.reduce pairs, trie(), fn { k, v }, dict ->
43+
@spec new(Enum.t) :: Dict.t
44+
def new(enum) do
45+
Enum.reduce enum, trie(), fn { k, v }, dict ->
4646
put(dict, k, v)
4747
end
4848
end
@@ -57,9 +57,9 @@ defmodule HashDict do
5757
#=> #HashDict<[{"a","a"},{"b","b"}]>
5858
5959
"""
60-
@spec new(list, (term -> {key :: term, value ::term})) :: Dict.t
61-
def new(list, transform) when is_function(transform) do
62-
Enum.reduce list, trie(), fn i, dict ->
60+
@spec new(Enum.t, (term -> {key :: term, value ::term})) :: Dict.t
61+
def new(enum, transform) when is_function(transform) do
62+
Enum.reduce enum, trie(), fn i, dict ->
6363
{ k, v } = transform.(i)
6464
put(dict, k, v)
6565
end

0 commit comments

Comments
 (0)