ringlist

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ringlist implements a capacity limited linked list based on ring.Ring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List struct {
	// contains filtered or unexported fields
}

List is a list with capacity and overflow cleanup.

func New

func New(cap int) *List

New creates an empty list with capacity cap. When cap == 0, the list has infinite capacity.

func (*List) Back

func (l *List) Back() *ring.Ring

Back returns the last element of list l or nil if the list is empty.

func (*List) Do

func (l *List) Do(f func(value interface{}) bool)

Do calls function f on each element of the list, in forward order. If f returns false, Do stops the iteration. f must not change l.

func (*List) Front

func (l *List) Front() *ring.Ring

Front returns the first element of list l or nil if the list is empty.

func (*List) Len

func (l *List) Len() int

Len returns the number of elements in list l.

func (*List) Move

func (l *List) Move(r *ring.Ring, delta int)

Move moves element r forward or backwards by at most delta positions or until the element becomes the front or back element in the list.

func (*List) MoveAfter

func (l *List) MoveAfter(r, mark *ring.Ring)

MoveAfter moves an element to its new position after mark.

func (*List) MoveBefore

func (l *List) MoveBefore(r, mark *ring.Ring)

MoveAfter moves an element to its new position before mark.

func (*List) MoveToBack

func (l *List) MoveToBack(r *ring.Ring)

MoveToBack moves the element to the back of list l.

func (*List) MoveToFront

func (l *List) MoveToFront(r *ring.Ring)

MoveToFront moves the element to the front of list l.

func (*List) PushBack

func (l *List) PushBack(r *ring.Ring) (front interface{})

PushBack inserts an element at the back of list l. If capacity is exceeded, the front element is removed and its value returned.

func (*List) PushFront

func (l *List) PushFront(r *ring.Ring) (back interface{})

PushBack inserts an element at the front of list l. If capacity is exceeded, the back element is removed and its value returned.

func (*List) Remove

func (l *List) Remove(r *ring.Ring) (value interface{})

Remove an element from the list.

Jump to

Keyboard shortcuts

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