linkedmap

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoublyLinkedList added in v0.12.0

type DoublyLinkedList[T any] struct {
	Head *LinkNode[T]
	Tail *LinkNode[T]
	// contains filtered or unexported fields
}

DoublyLinkedList represents a doubly linked list

func NewDoublyLinkedList added in v0.12.0

func NewDoublyLinkedList[T any]() *DoublyLinkedList[T]

func (*DoublyLinkedList[T]) Clear added in v0.12.0

func (l *DoublyLinkedList[T]) Clear()

Clear removes all nodes from the list, making it empty

func (*DoublyLinkedList[T]) Delete added in v0.12.0

func (l *DoublyLinkedList[T]) Delete(ln *LinkNode[T])

Delete removes a specific node from the list

func (*DoublyLinkedList[T]) DeleteAtHead added in v0.12.0

func (l *DoublyLinkedList[T]) DeleteAtHead()

DeleteAtHead deletes the node at the head of the list

func (*DoublyLinkedList[T]) DeleteAtTail added in v0.12.0

func (l *DoublyLinkedList[T]) DeleteAtTail()

DeleteAtTail deletes the node at the tail of the list

func (*DoublyLinkedList[T]) InsertAtHead added in v0.12.0

func (l *DoublyLinkedList[T]) InsertAtHead(data T) *LinkNode[T]

InsertAtHead inserts a new node at the head of the list

func (*DoublyLinkedList[T]) InsertAtTail added in v0.12.0

func (l *DoublyLinkedList[T]) InsertAtTail(data T) *LinkNode[T]

InsertAtTail appends a new node at the tail of the list

func (*DoublyLinkedList[T]) Length added in v0.12.0

func (l *DoublyLinkedList[T]) Length() int

Length returns the number of nodes in the list

func (*DoublyLinkedList[T]) Values added in v0.12.0

func (l *DoublyLinkedList[T]) Values() []T

Values returns a slice of values in the list

type LinkNode added in v0.12.0

type LinkNode[T any] struct {
	Data T
	Next *LinkNode[T]
	Prev *LinkNode[T]
}

func NewLinkNode added in v0.12.0

func NewLinkNode[T any](data T) *LinkNode[T]

type LinkedMap

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

func NewLinkedMap

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

NewLinkedMap 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) *LinkNode[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() *LinkNode[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]) 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() *LinkNode[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