mguimas
Hi,
it seems there are several (too many, I think) options for making sets, but no clue which one to choose in which situations, like number of elements in the collection, speed and space complexity, to name a few factors.
How do you choose between all these options when you need to use element sets in your applications?
Thanks,
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
Mapis not a set. You can implement one on top of it, then you get aMapSet.setsandgb_setsare some erlang implementations of different sets, also there isordsets.I’m not sure about how
setsis implemented,ordsetsthough is just an ordered list of elements.gb_setsuses a self balancing tree to implement an ordered set.In elixir code, I’d always prefer
MapSet, as its interface just fits into elixir, as its designed for/in it.In erlang code though I quite often just use
sets, because it has the shortest module namebenwilson512
Some of the erlang modules are effectively legacy implementations from before Maps existed on which you could build MapSet. I believe there are benchmarks which show MapSet to be faster on all operations than the original
sets.mguimas
I would say that by default one should then opt for
MapSet, and to consider the other options if rewriting the application-level algorithm is not enough to get the desired increase in performance.I see a use of
Mapto implement a set in those cases where aMapSet.popwould be handy. I believe that mimicking such non-existent function viaMapSet.member?followed byMapSet.deletecan be slower when data is large, otherwiseMapwould not need to provide such function.peerreynders
https://github.com/elixir-lang/elixir/blob/v1.9.1/lib/elixir/lib/map_set.ex#L138-L140
https://github.com/elixir-lang/elixir/blob/v1.9.1/lib/elixir/lib/map.ex#L631-L636
LostKobrakai
MapSet is an opaque datatype though. So this would make dialyzer scream at you.
peerreynders
I would have expected as much.
I see this as an optimization of edge functionality - I want this value removed from the set and know whether it existed in the set - in the service of still using a type that communicates the nature of a set rather than that of a key value store for its overall intended use.
The tradeoff I see here is that I can still use
MapSetwhere appropriate (rather thanMap) but am potentially forced to take extra steps to placate dialyzer for the optimized edge functionality (i.e.popon a set).