list

package
v0.0.0-...-8299741 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: GPL-3.0 Imports: 0 Imported by: 2

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 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

func (h *Head) Delete()

Delete deletes h from its list.

func (*Head) Init

func (h *Head) Init()

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

func (*Head) MoveBefore

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

func (h *Head) Next() *Head

func (*Head) Prev

func (h *Head) Prev() *Head

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL