go123: lab.nexedi.com/kirr/go123/xcontainer/list Index | Files

package list

import "lab.nexedi.com/kirr/go123/xcontainer/list"

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.


Package Files


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) Delete Uses

func (h *Head) Delete()

Delete deletes h from its list.

func (*Head) Init Uses

func (h *Head) Init()

Init initializes a head making it point to itself via .next and .prev .

func (*Head) MoveBefore Uses

func (a *Head) MoveBefore(b *Head)

MoveBefore moves a to be before b.

XXX ok to move if a was not previously on the list?

func (*Head) Next Uses

func (h *Head) Next() *Head

func (*Head) Prev Uses

func (h *Head) Prev() *Head

Package list is imported by 1 packages. Updated 2020-07-07. Refresh now. Tools for package owners.