Could anybody please explain me a few things about Elixir data types:
1) What are the sets and when should I use them?
2) What is the difference between HashSet
and MapSet
?
3) What is HashDict
and when should I use it?
Could anybody please explain me a few things about Elixir data types:
1) What are the sets and when should I use them?
2) What is the difference between HashSet
and MapSet
?
3) What is HashDict
and when should I use it?
use sets when you need to strictly enforce that every element can appear only once. They are quite rare and I would not bother with them until you run into a specific problem where they are useful.
the difference is the underlying implementation. With the latest Erlang VM R18, MapSet is faster: https://gist.github.com/lexmag/32977ce8fd7cb44ddefa
HashDict is deprecated and should not be used in new projects, also see What is the benefit of Keyword Lists?