linked
Package linked
import "github.com/luxfi/node/utils/linked"Functions
InsertAfter
func InsertAfter[T any](l *List[T], v T, location *ListElement[T])InsertAfter inserts v into a new element immediately after location. If location is not in l, l is not modified.
InsertBefore
func InsertBefore[T any](l *List[T], v T, location *ListElement[T])InsertBefore inserts v into a new element immediately before location. If location is not in l, l is not modified.
PushBack
func PushBack[T any](l *List[T], v T)PushBack inserts v into a new element at the back of l.
PushFront
func PushFront[T any](l *List[T], v T)PushFront inserts v into a new element at the front of l.
Types
Hashmap
Hashmap provides an ordered O(1) mapping from keys to values.
Entries are tracked by insertion order.
func NewHashmap[K comparable, V any]() *Hashmap[K, V]func NewHashmapWithSize[K comparable, V any](initialSize int) *Hashmap[K, V]func (lh *Hashmap[K, V]) Clear()func (lh *Hashmap[K, V]) Delete(key K) boolfunc (lh *Hashmap[K, V]) Get(key K) (V, bool)func (lh *Hashmap[K, V]) Len() intfunc (lh *Hashmap[K, V]) NewIterator() *Iterator[K, V]func (lh *Hashmap[K, V]) Newest() (K, V, bool)func (lh *Hashmap[K, V]) Oldest() (K, V, bool)func (lh *Hashmap[K, V]) Put(key K, value V)Iterator
Iterates over the keys and values in a LinkedHashmap from oldest to newest. Assumes the underlying LinkedHashmap is not modified while the iterator is in use, except to delete elements that have already been iterated over.
func (it *Iterator[K, V]) Key() Kfunc (it *Iterator[K, V]) Next() boolfunc (it *Iterator[K, V]) Value() VList
List implements a doubly linked list with a sentinel node.
See: https://en.wikipedia.org/wiki/Doubly_linked_list
This datastructure is designed to be an almost complete drop-in replacement for the standard library's "container/list".
The primary design change is to remove all memory allocations from the list definition. This allows these lists to be used in performance critical paths. Additionally the zero value is not useful. Lists must be created with the NewList method.
func NewList[T any]() *List[T]func (l *List[T]) Back() *ListElement[T]func (l *List[T]) Front() *ListElement[T]func (l *List[T]) InsertAfter(e *ListElement[T], location *ListElement[T])func (l *List[T]) InsertBefore(e *ListElement[T], location *ListElement[T])func (l *List[_]) Len() intfunc (l *List[T]) MoveAfter(e, location *ListElement[T])func (l *List[T]) MoveBefore(e, location *ListElement[T])func (l *List[T]) MoveToBack(e *ListElement[T])func (l *List[T]) MoveToFront(e *ListElement[T])func (l *List[T]) PushBack(e *ListElement[T])func (l *List[T]) PushFront(e *ListElement[T])func (l *List[T]) Remove(e *ListElement[T])ListElement
ListElement is an element of a linked list.
func (e *ListElement[T]) Next() *ListElement[T]func (e *ListElement[T]) Prev() *ListElement[T]