# Learning idiomatic Elixir - Q1

**URL:** <https://forum.elixirforum.com/t/learning-idiomatic-elixir-q1/57934>\
**Category:** Questions\
**Tags:** code-review, idiomatic-elixir\
**Created:** [August 29, 2023, 1:14pm UTC](https://forum.elixirforum.com/t/learning-idiomatic-elixir-q1/57934 "2023-08-29T13:14:37Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![eksperimental](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eksperimental/32/1401_2.png) [@eksperimental](https://forum.elixirforum.com/u/eksperimental)\
**Post date:** [September 5, 2023, 8:20am UTC](https://forum.elixirforum.com/t/learning-idiomatic-elixir-q1/57934/17 "2023-09-05T08:20:47Z")

</div>

There’s a relevant discussion in the forum related to constant time access.

> [@Way to get O(1) access/set](https://forum.elixirforum.com/t/way-to-get-o-1-access-set/24471):
>
> Hey Everyone, 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…

The possible options seem to be using tuples or ETS tables.  
Another alternative would be to create your own constant-time-access structure, which is a struct, but internally it uses a tuple. You could take as an inspirations @Qqwy’s library Array, [GitHub - Qqwy/elixir-arrays: Well-structured Arrays with fast random-element-access for Elixir, offering a common interface with multiple implementations with varying performance guarantees that can be switched in your configuration. · GitHub](https://github.com/Qqwy/elixir-arrays)

I will play with different solutions and come back to it when I have time.

---

_[View the full topic](https://forum.elixirforum.com/t/learning-idiomatic-elixir-q1/57934)._
