Documentation ¶
Index ¶
- type Element
- type LinkedList
- func (ll *LinkedList[T]) Clear()
- func (ll *LinkedList[T]) Delete(elm *Element[T])
- func (ll *LinkedList[T]) DeleteAtHead()
- func (ll *LinkedList[T]) DeleteAtTail()
- func (ll *LinkedList[T]) InsertAfter(data T, pos *Element[T]) *Element[T]
- func (ll *LinkedList[T]) InsertAtHead(data T) *Element[T]
- func (ll *LinkedList[T]) InsertAtTail(data T) *Element[T]
- func (ll *LinkedList[T]) InsertBefore(data T, pos *Element[T]) *Element[T]
- func (ll *LinkedList[T]) Length() int
- func (ll *LinkedList[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
func NewElement ¶
type LinkedList ¶
type LinkedList[T any] struct { Head *Element[T] Tail *Element[T] // contains filtered or unexported fields }
LinkedList represents a doubly linked list.
func New ¶
func New[T any]() *LinkedList[T]
func (*LinkedList[T]) Clear ¶
func (ll *LinkedList[T]) Clear()
Clear removes all elements from the list, making it empty.
func (*LinkedList[T]) Delete ¶
func (ll *LinkedList[T]) Delete(elm *Element[T])
Delete removes a specific element from the list.
func (*LinkedList[T]) DeleteAtHead ¶
func (ll *LinkedList[T]) DeleteAtHead()
DeleteAtHead deletes the element at the head of the list.
func (*LinkedList[T]) DeleteAtTail ¶
func (ll *LinkedList[T]) DeleteAtTail()
DeleteAtTail deletes the element at the tail of the list.
func (*LinkedList[T]) InsertAfter ¶
func (ll *LinkedList[T]) InsertAfter(data T, pos *Element[T]) *Element[T]
func (*LinkedList[T]) InsertAtHead ¶
func (ll *LinkedList[T]) InsertAtHead(data T) *Element[T]
InsertAtHead inserts a new element at the head of the list.
func (*LinkedList[T]) InsertAtTail ¶
func (ll *LinkedList[T]) InsertAtTail(data T) *Element[T]
InsertAtTail appends a new element at the tail of the list.
func (*LinkedList[T]) InsertBefore ¶
func (ll *LinkedList[T]) InsertBefore(data T, pos *Element[T]) *Element[T]
func (*LinkedList[T]) Length ¶
func (ll *LinkedList[T]) Length() int
Length returns the number of elements in the list.
func (*LinkedList[T]) Values ¶
func (ll *LinkedList[T]) Values() []T
Values returns a slice of values in the list.
Click to show internal directories.
Click to hide internal directories.