I'm reading about unrolled linked lists and have found two different ways to make one. The book I have implements one like this:
// Node
typedef struct node {
int data;
struct node *next;
} Node;
// Block of nodes
typedef struct linkedblock {
struct linkedblock *next;
Node *head;
int nodeCount;
} LinkedBlock;
however Wikipedia shows that instead of LinkedBlock
having a pointer to a Node
, it has an array. I think this might be so that the memory is contiguous and something about cache efficiency? Is there other advantages to doing it this way? Is the way my book implements it less optimized/worse? Does there happen to be a common or preferred way?
I'm trying to implement an unrolled linked list so I can learn how they work, but also in case I need to use one in the future (I strangely can't find any C implementations on GitHub or elsewhere). Basically I'd like to know which of the two ways would be more likely to be used in real applications. Also is this a data structure I shouldn't waste too much time learning? Because in my other algorithms book (CLRS) I don't even see it mentioned.