HAMT: Hash Array Mapped Trie. This data structure makes efficient immutable data possible. You can update a list of a million items, and keep a reference to the original list, by changing 3 or 4 references and some bytes. This should replace copy-on-write for scripting languages. I really want to see it in a JS spec soon. There are libraries that can do it, but they add translation penalties and extra steps. I’d comp…
Ask HN: What are some cool but obscure data structures you know about?
211–220 of 772 posts
Re: Ask HN: What are some cool but obscure data structures you know about?
#212Re: Ask HN: What are some cool but obscure data structures you know about?
#213https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_s...
Re: Ask HN: What are some cool but obscure data structures you know about?
#214Cache-Oblivious Data Structures: https://cs.au.dk/~gerth/MassiveData02/notes/demaine.pdf A vaguely related notion is that naive analysis of big-O complexity in typical CS texts ignores over the increasing latency/cost of data access as the data size grows. This can't be ignored, no matter how much we would like to hand-wave it away, because physics gets in the way. A way to think about it is that a CPU core is like a…
Cache oblivious algorithms attempt to make the memory access term insignificant so you could continue to ignore it. They are super neat.
Re: Ask HN: What are some cool but obscure data structures you know about?
#215The Zipper acts like a linked-list with a cursor, or "focused element"; it's implemented as a pair of lists in opposite orders; or, equivalently but more symmetric, as triple of (List[A], A, List[A]) Say we have a zipper containing [0, 1, 2, 3, 4, 5], and we're focusing on the 3. In code this will look like: ([2, 1, 0], 3, [4, 5]) Where [a, b, c] denotes a singly-linked list, with O(1) head (returning a) and tail (re…
Re: Ask HN: What are some cool but obscure data structures you know about?
#216Re: Ask HN: What are some cool but obscure data structures you know about?
#217Re: Ask HN: What are some cool but obscure data structures you know about?
#218Earlier quoted context omitted.
Have you used this before? What was the domain?
I have seen this general pattern in several decently large game object systems, although I can’t think of which ones off hand, if I’m recalling correctly it tend to be used in the longer lived (aka 10s of frames) object status/object existence checks, and often in AI subsystems, pathing and general decision making queries, etc.
Re: Ask HN: What are some cool but obscure data structures you know about?
#219Earlier quoted context omitted.
A deque may be implemented as a linked list, but it's actually more common to be implemented on top of arrays. Python in particular uses arrays under the hood for almost everything because modern computer hardware is so blazingly fast manipulating them.
Arrays aren't efficient when you want to add/remove to the head. Deque in python exists so there is a data structure with constant time pop/push to the head. And it is in fact implemented as a doubly linked list, with various optimizations: https://github.com/python/cpython/blob/v3.8.1/Modules/_colle... .
Re: Ask HN: What are some cool but obscure data structures you know about?
#220HAMT: Hash Array Mapped Trie. This data structure makes efficient immutable data possible. You can update a list of a million items, and keep a reference to the original list, by changing 3 or 4 references and some bytes. This should replace copy-on-write for scripting languages. I really want to see it in a JS spec soon. There are libraries that can do it, but they add translation penalties and extra steps. I’d comp…