Implementation of an UnrolledLinkedList for storage of nodes. This collection is primarily for use within an {@link org.neo4j.collections.indexedrelationship.IndexedRelationship}. The benefits of the UnrolledLinkedList is that it has very good performance in cases where items are added at the head of the list, and items are generally read from the head in the order they are added.
The structure is broken into "pages" of links to nodes where the size of the page can be controlled at initial construction time. Page size is not fixed but instead can float between a lower bound, and an upper bound. The bounds are at a fixed margin from the page size of M. When a page drops below the lower bound it will be joined onto the an adjacent page, and when the page goes above the upper bound it will be split in half.
IMPORTANT NOTE: the margin must be greater than a third of the page size in order to stop a page being split, then both pages being lower than the lower bound, the default margin is 1/2 page size.
The exception to the bounds is the head page which can contain less than the lower bound. A new head page is created when adding a new node to the current head would put it above the page size, and instead a new head will be created that has a single node in it.
There is a trade off between page size and number of page to page relationships need to be followed. As nodes are not stored sorted within the page they must all be read in and compared using the comparator in order to iterate over them in order. However any given node within P(X) will be in order compared to any given node within P(X+1).
A perfect example would be an inbox where content is added sorted by date and always added in increasing date order. Then the content is read out from most recent backwards in time and generally only the first page of content is retrieved.
This data structure is not as good as a sorted tree when content is added randomly against the given order, or where the items have their position within the list change based on data changes.