Documentation ¶
Overview ¶
Package list provides intrusive double-linked lists.
Go standard library has container/list package which already provides double-linked lists. However in that implementation list itself is kept separate from data structures representing elements. This package provides alternative approach where elements embed necessary list heads which is sometimes more convenient, for example when one wants to move a list element in O(1) starting from pointer to just its data.
TODO doc how to get to container of list head via unsafe.OffsetOf.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Head ¶
type Head struct {
// contains filtered or unexported fields
}
Head is a list head entry for an element in an intrusive doubly-linked list.
Zero HEAD value is NOT valid - always call Init() to initialize a head before using it.
func (*Head) Init ¶
func (h *Head) Init()
Init initializes a head making it point to itself via .next and .prev .
func (*Head) MoveBefore ¶
MoveBefore moves a to be before b.
XXX ok to move if a was not previously on the list?