Documentation ¶
Index ¶
- func InsertAfter[T any](l *List[T], v T, location *ListElement[T])
- func InsertBefore[T any](l *List[T], v T, location *ListElement[T])
- func PushBack[T any](l *List[T], v T)
- func PushFront[T any](l *List[T], v T)
- type Hashmap
- func (lh *Hashmap[K, V]) Clear()
- func (lh *Hashmap[K, V]) Delete(key K) bool
- func (lh *Hashmap[K, V]) Get(key K) (V, bool)
- func (lh *Hashmap[K, V]) Len() int
- func (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)
- type Iterator
- type List
- 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() int
- func (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])
- type ListElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func 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.
func 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.
Types ¶
type Hashmap ¶
type Hashmap[K comparable, V any] struct { // contains filtered or unexported fields }
Hashmap provides an ordered O(1) mapping from keys to values.
Entries are tracked by insertion order.
func NewHashmap ¶
func NewHashmap[K comparable, V any]() *Hashmap[K, V]
func NewHashmapWithSize ¶
func NewHashmapWithSize[K comparable, V any](initialSize int) *Hashmap[K, V]
func (*Hashmap[K, V]) NewIterator ¶
type Iterator ¶
type Iterator[K comparable, V any] struct { // contains filtered or unexported fields }
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.
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
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 (*List[T]) Back ¶
func (l *List[T]) Back() *ListElement[T]
Back returns the element at the back of l. If l is empty, nil is returned.
func (*List[T]) Front ¶
func (l *List[T]) Front() *ListElement[T]
Front returns the element at the front of l. If l is empty, nil is returned.
func (*List[T]) InsertAfter ¶
func (l *List[T]) InsertAfter(e *ListElement[T], location *ListElement[T])
InsertAfter inserts e immediately after location. If e is already in a list, l is not modified. If location is not in l, l is not modified.
func (*List[T]) InsertBefore ¶
func (l *List[T]) InsertBefore(e *ListElement[T], location *ListElement[T])
InsertBefore inserts e immediately before location. If e is already in a list, l is not modified. If location is not in l, l is not modified.
func (*List[T]) MoveAfter ¶
func (l *List[T]) MoveAfter(e, location *ListElement[T])
MoveAfter moves e immediately after location. If the elements are equal or not in l, the list is not modified.
func (*List[T]) MoveBefore ¶
func (l *List[T]) MoveBefore(e, location *ListElement[T])
MoveBefore moves e immediately before location. If the elements are equal or not in l, the list is not modified.
func (*List[T]) MoveToBack ¶
func (l *List[T]) MoveToBack(e *ListElement[T])
MoveToBack moves e to the back of l. If e is not in l, l is not modified.
func (*List[T]) MoveToFront ¶
func (l *List[T]) MoveToFront(e *ListElement[T])
MoveToFront moves e to the front of l. If e is not in l, l is not modified.
func (*List[T]) PushBack ¶
func (l *List[T]) PushBack(e *ListElement[T])
PushBack inserts e at the back of l. If e is already in a list, l is not modified.
func (*List[T]) PushFront ¶
func (l *List[T]) PushFront(e *ListElement[T])
PushFront inserts e at the front of l. If e is already in a list, l is not modified.
func (*List[T]) Remove ¶
func (l *List[T]) Remove(e *ListElement[T])
Remove removes e from l if e is in l.
type ListElement ¶
type ListElement[T any] struct { Value T // contains filtered or unexported fields }
ListElement is an element of a linked list.
func (*ListElement[T]) Next ¶
func (e *ListElement[T]) Next() *ListElement[T]
Next returns the next element or nil.
func (*ListElement[T]) Prev ¶
func (e *ListElement[T]) Prev() *ListElement[T]
Prev returns the previous element or nil.