Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

7-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.


If I have this right, what you've built is this, storing M items in M / N nodes where N is the radix of the array?

    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 < i
           acc += N
           node = node.next
        return node.array[j - acc]
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.


You're probably right, I was in college back then and wanted to work on something cool, this was my idea.


It was fun because you didn't write it in Rust :)

https://rust-unofficial.github.io/too-many-lists/


Similar to an unrolled linked list: https://en.wikipedia.org/wiki/Unrolled_linked_list

But you size the nodes dynamically, rather than using a fixed size.


I believe that's called a "rope"


Rope is binary tree of arrays, for O(logN) index operation.


Ah, my bad. What's the name for the thing he's talking about?


It's called an "unrolled" linked list




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: