Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Unrolled linked list
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== A typical unrolled linked list node looks like this: '''[[record (computer science)|record]]''' node { ''node'' next ''// reference to next node in list'' ''int'' numElements ''// number of elements in this node, up to maxElements'' ''array'' elements ''// an array of numElements elements,'' ''// with space allocated for maxElements elements'' } Each node holds up to a certain maximum number of elements, typically just large enough so that the node fills a single [[cache line]] or a small multiple thereof. A position in the list is indicated by both a reference to the node and a position in the elements array. It is also possible to include a ''previous'' pointer for an unrolled [[doubly linked list]]. To insert a new element, we find the node the element should be in and insert the element into the <code>elements</code> array, incrementing <code>numElements</code>. If the array is already full, we first insert a new node either preceding or following the current one and move half of the elements in the current node into it. To remove an element, we find the node it is in and delete it from the <code>elements</code> array, decrementing <code>numElements</code>. If this reduces the node to less than half-full, then we move elements from the next node to fill it back up above half. If this leaves the next node less than half full, then we move all its remaining elements into the current node, then bypass and delete it.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)