linkedmap

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkedMap

type LinkedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func New added in v0.19.0

func New[K comparable, V any](capacity int) *LinkedMap[K, V]

New creates a new LinkedMap with the specified capacity.

func (*LinkedMap[K, V]) Capacity

func (lm *LinkedMap[K, V]) Capacity() int

Capacity returns the capacity of the LinkedMap.

func (*LinkedMap[K, V]) Clear

func (lm *LinkedMap[K, V]) Clear()

Clear removes all key-value pairs from the LinkedMap, making it empty.

func (*LinkedMap[K, V]) Empty

func (lm *LinkedMap[K, V]) Empty() bool

Empty checks if the LinkedMap is empty (contains no key-value pairs).

func (*LinkedMap[K, V]) Full

func (lm *LinkedMap[K, V]) Full() bool

Full checks if the LinkedMap is full (reached its capacity).

func (*LinkedMap[K, V]) GetNode added in v0.12.0

func (lm *LinkedMap[K, V]) GetNode(key K) *ll.Element[Pair[K, V]]

GetNode returns the LinkNode corresponding to the specified key.

func (*LinkedMap[K, V]) Has

func (lm *LinkedMap[K, V]) Has(key K) bool

Has checks if the specified key exists in the LinkedMap.

func (*LinkedMap[K, V]) HeadNode added in v0.12.0

func (lm *LinkedMap[K, V]) HeadNode() *ll.Element[Pair[K, V]]

HeadNode returns the LinkNode at the beginning (head) of the LinkedMap.

func (*LinkedMap[K, V]) PushBack

func (lm *LinkedMap[K, V]) PushBack(key K, value V)

PushBack adds a new key-value pair to the end of the LinkedMap.

func (*LinkedMap[K, V]) PushFront

func (lm *LinkedMap[K, V]) PushFront(key K, value V)

PushFront adds a new key-value pair to the beginning of the LinkedMap.

func (*LinkedMap[K, V]) Remove

func (lm *LinkedMap[K, V]) Remove(key K) bool

Remove removes the key-value pair with the specified key from the LinkedMap. It returns true if the key was found and removed, otherwise false.

func (*LinkedMap[K, V]) RemoveHead added in v0.19.0

func (lm *LinkedMap[K, V]) RemoveHead()

func (*LinkedMap[K, V]) RemoveTail added in v0.19.0

func (lm *LinkedMap[K, V]) RemoveTail()

func (*LinkedMap[K, V]) SetCapacity

func (lm *LinkedMap[K, V]) SetCapacity(capacity int)

SetCapacity sets the capacity of the LinkedMap and prunes the excess elements if needed.

func (*LinkedMap[K, V]) Size

func (lm *LinkedMap[K, V]) Size() int

Size returns the number of key-value pairs in the LinkedMap.

func (*LinkedMap[K, V]) TailNode added in v0.12.0

func (lm *LinkedMap[K, V]) TailNode() *ll.Element[Pair[K, V]]

TailNode returns the LinkNode at the end (tail) of the LinkedMap.

type Pair

type Pair[K comparable, V any] struct {
	Key   K
	Value V
}

Jump to

Keyboard shortcuts

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