Documentation
¶
Index ¶
- type Cursor
- type LinkedList
- func (ll *LinkedList[T]) CursorGhost() *Cursor[T]
- func (ll *LinkedList[T]) CursorHead() *Cursor[T]
- func (ll *LinkedList[T]) CursorTail() *Cursor[T]
- func (ll *LinkedList[T]) Iter() Iterator[T]
- func (ll *LinkedList[T]) IterReverse() Iterator[T]
- func (ll *LinkedList[T]) Len() int
- func (ll *LinkedList[T]) Pop() *T
- func (ll *LinkedList[T]) PopHead() *T
- func (ll *LinkedList[T]) Push(item T)
- func (ll *LinkedList[T]) PushHead(item T)
- func (ll *LinkedList[T]) Reverse()
- func (ll *LinkedList[T]) ToSlice() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor[T any] struct { // contains filtered or unexported fields }
func (*Cursor[T]) InsertAfter ¶
func (c *Cursor[T]) InsertAfter(item T)
func (*Cursor[T]) InsertBefore ¶
func (c *Cursor[T]) InsertBefore(item T)
func (*Cursor[T]) RemoveCurrent ¶
func (c *Cursor[T]) RemoveCurrent() *T
func (*Cursor[T]) SetCurrent ¶
func (c *Cursor[T]) SetCurrent(val T)
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
func NewLinkedList ¶
func NewLinkedList[T any](items ...T) LinkedList[T]
func (*LinkedList[T]) CursorGhost ¶
func (ll *LinkedList[T]) CursorGhost() *Cursor[T]
CursorGhost returns a cursor pointing to the "ghost" node, which logically lies before head and after tail.
func (*LinkedList[T]) CursorHead ¶
func (ll *LinkedList[T]) CursorHead() *Cursor[T]
CursorHead returns a cursor pointing to the first node in the linked list. If the list is empty, the cursor will point to the "ghost" node.
func (*LinkedList[T]) CursorTail ¶
func (ll *LinkedList[T]) CursorTail() *Cursor[T]
CursorTail returns a cursor pointing to the last node in the linked list. If the list is empty, the cursor will point to the "ghost" node.
func (*LinkedList[T]) Iter ¶
func (ll *LinkedList[T]) Iter() Iterator[T]
func (*LinkedList[T]) IterReverse ¶
func (ll *LinkedList[T]) IterReverse() Iterator[T]
func (*LinkedList[T]) Len ¶
func (ll *LinkedList[T]) Len() int
Len returns the length of the linked list.
func (*LinkedList[T]) Pop ¶
func (ll *LinkedList[T]) Pop() *T
Pop will remove and return the last node of the linked list. If the list is empty, it will return nil.
func (*LinkedList[T]) PopHead ¶
func (ll *LinkedList[T]) PopHead() *T
PopHead will remove the first node of the linked list and return it. If the list is empty, it will return nil.
func (*LinkedList[T]) Push ¶
func (ll *LinkedList[T]) Push(item T)
Push will add the given value as a node to the end of the linked list.
func (*LinkedList[T]) PushHead ¶
func (ll *LinkedList[T]) PushHead(item T)
PushHead will add the provided value as a node at the front of the linked list.
func (*LinkedList[T]) ToSlice ¶
func (ll *LinkedList[T]) ToSlice() []T
ToSlice collects the nodes of the linked list and returns them as a slice.