What is a good general purpose way to get O(1) access and set operations in Elixir?
Is there a way to specify that a Map is in a “build state” then transition it to an access state so that a flat hash map structure could be used to allow O(1) access/O(n) building?
I understand the reason that the raw elixir maps cannot be both O(1) access and insert while being immutable, but in this sort of structure it seems something like this would be possible:
builder = FastMap.Builder.new() builder = FastMap.Builder.put(:key, :val) map = FastMap.build(builder) # now after building we can access :val = FastMap.get(map, :key) # match successful
Does anything like this exist? If not then maybe I should take a stab at implementing it!
It seems like at some point in the development of Elixir as a language a general purpose O(1) set/access data structure would be essential!
If anything similar exists I’d love to be pointed that direction, if this is a common gap in what already exists in Elixir seems like something I should implement!