Fast linked lists
dygalo.dev
Fast linked lists
1–10 of 131 posts
Re: Fast linked lists
#2Re: Fast linked lists
#37-8 years ago I created GlueList ( https://github.com/ertugrulcetin/GlueList ) in order to build faster version of LinkedList + ArrayList. It was a fun effort.
Re: Fast linked lists
#4Re: Fast linked lists
#5Re: Fast linked lists
#6Re: Fast linked lists
#7Re: Fast linked lists
#87-8 years ago I created GlueList ( https://github.com/ertugrulcetin/GlueList ) in order to build faster version of LinkedList + ArrayList. It was a fun effort.
Re: Fast linked lists
#97-8 years ago I created GlueList ( https://github.com/ertugrulcetin/GlueList ) in order to build faster version of LinkedList + ArrayList. It was a fun effort.
0 1 M / Nth node
[ N elem ] [.] -> [N elem] [.] -> .... -> [M - (M / N) elem] [null]
And so if you want to index the `i`th element you chase the pointers index (node i) :
acc = 0
while acc + N
Or something like that? You can do better using a B tree and exploit the fact that you don't need keys to just store pointers in the branch nodes. This reduces the number of pointer dereferences in large arrays.For example say you have N = 8 and there are 1024 elements in the list, you would need 127 pointer dereferences to reach the end of the array. In a B-tree you only have 3. (double check my math, I might be off by one).
This is the typical implementation for immutable/persistent vector types. If you keep the links between leave nodes at the bottom of the tree, you've got a B+ tree and have fast iteration through it as well.
Re: Fast linked lists
#10Linked list benchmarks are amazing.... if you don't thrash your cache on inserts so all its elements are contiguous. You get all the benefits of a vector and a linked list, without the reality that linked lists mostly don't get populated 100% consecutively, and thus can be anywhere in memory.