list

package
v1.0.2-stable Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int
const (
	FromFront Direction = iota
	FromBack
)

type Element

type Element[T types.Sized] struct {
	// contains filtered or unexported fields
}

Element is a reusable node for the doubly linked list.

func (*Element[T]) List

func (e *Element[T]) List() *List[T]

func (*Element[T]) Next

func (e *Element[T]) Next() *Element[T]

func (*Element[T]) Prev

func (e *Element[T]) Prev() *Element[T]

func (*Element[T]) Value

func (e *Element[T]) Value() T

func (*Element[T]) Weight

func (e *Element[T]) Weight() int64

type List

type List[T types.Sized] struct {
	// contains filtered or unexported fields
}

List is a shard-local doubly linked list for LRU order.

func New

func New[T types.Sized]() *List[T]

New creates a new List with its own mutex.

func (*List[T]) Back

func (l *List[T]) Back() *Element[T]

Back returns the last element or nil if empty.

func (*List[T]) FreeElement added in v1.0.1

func (l *List[T]) FreeElement(e *Element[T])

func (*List[T]) Len

func (l *List[T]) Len() int

Len returns the length, safe for concurrent read.

func (*List[T]) MoveToFront

func (l *List[T]) MoveToFront(e *Element[T])

MoveToFront moves e to the front.

func (*List[T]) Next

func (l *List[T]) Next(offset int) (*Element[T], bool)

Next returns the element at offset from front.

func (*List[T]) PushBack

func (l *List[T]) PushBack(v T) *Element[T]

PushBack adds v at the back and returns the element.

func (*List[T]) PushFront

func (l *List[T]) PushFront(v T) *Element[T]

PushFront adds v at the front and returns the element.

func (*List[T]) Remove

func (l *List[T]) Remove(e *Element[T])

Remove deletes e from the list.

func (*List[T]) Sort

func (l *List[T]) Sort(ord Order)

type Order

type Order int
const (
	DESC Order = iota
	ASC
)

Jump to

Keyboard shortcuts

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