Documentation
¶
Index ¶
- type DoublyLinkedList
- func (l *DoublyLinkedList[T]) Clear()
- func (l *DoublyLinkedList[T]) Delete(ln *LinkNode[T])
- func (l *DoublyLinkedList[T]) DeleteAtHead()
- func (l *DoublyLinkedList[T]) DeleteAtTail()
- func (l *DoublyLinkedList[T]) InsertAtHead(data T) *LinkNode[T]
- func (l *DoublyLinkedList[T]) InsertAtTail(data T) *LinkNode[T]
- func (l *DoublyLinkedList[T]) Length() int
- func (l *DoublyLinkedList[T]) Values() []T
- type LinkNode
- type LinkedMap
- func (lm *LinkedMap[K, V]) Capacity() int
- func (lm *LinkedMap[K, V]) Clear()
- func (lm *LinkedMap[K, V]) Empty() bool
- func (lm *LinkedMap[K, V]) Full() bool
- func (lm *LinkedMap[K, V]) GetNode(key K) *LinkNode[Pair[K, V]]
- func (lm *LinkedMap[K, V]) Has(key K) bool
- func (lm *LinkedMap[K, V]) HeadNode() *LinkNode[Pair[K, V]]
- func (lm *LinkedMap[K, V]) PushBack(key K, value V)
- func (lm *LinkedMap[K, V]) PushFront(key K, value V)
- func (lm *LinkedMap[K, V]) Remove(key K) bool
- func (lm *LinkedMap[K, V]) SetCapacity(capacity int)
- func (lm *LinkedMap[K, V]) Size() int
- func (lm *LinkedMap[K, V]) TailNode() *LinkNode[Pair[K, V]]
- type Pair
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
func NewLinkNode ¶ added in v0.12.0
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]) Clear ¶
func (lm *LinkedMap[K, V]) Clear()
Clear removes all key-value pairs from the LinkedMap, making it empty.
func (*LinkedMap[K, V]) Empty ¶
Empty checks if the LinkedMap is empty (contains no key-value pairs).
func (*LinkedMap[K, V]) GetNode ¶ added in v0.12.0
GetNode returns the LinkNode corresponding to the specified key.
func (*LinkedMap[K, V]) HeadNode ¶ added in v0.12.0
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 ¶
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 ¶
SetCapacity sets the capacity of the LinkedMap and prunes the excess elements if needed.
type Pair ¶
type Pair[K comparable, V any] struct { Key K Value V }