linkedlist

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Unlicense Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry[T any] interface {
	// Value() gets the value of the list entry.
	Value() T
	// Close() removes the entry from the list and returns the Entry to the
	// list's object pool. Referring to an Entry after its Close() method is
	// called is undefined behavior.
	Close()
	// Freshen removes the entry from the list, and re-adds it. This is
	// semantically equivalent to the following example implementation, except
	// that the Entry is not destroyed and can continue to be used:
	//
	// v := entry.Value()
	// entry.Close()
	// list.Append(v)
	Freshen()
}

Entry represents an entry in a List.

type List

type List[T any] interface {
	// Add an item to the list. Returns an [Entry] which can be used to remove
	// the item.
	Append(T) Entry[T]
	// Get the least recently added item from the list.
	Last() Entry[T]
	// Get the number of items in the list.
	Len() int
}

List implements a doubly-linked list. It works as a FIFO, except that it allowd removing arbitrary items.

func New

func New[T any]() List[T]

Create a new List

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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