linkedlist

package
v0.0.0-...-0f152c1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 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 Cursor

type Cursor[T any] struct {
	// contains filtered or unexported fields
}

func (*Cursor[T]) Current

func (c *Cursor[T]) Current() *T

func (*Cursor[T]) Index

func (c *Cursor[T]) Index() *int

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]) Next

func (c *Cursor[T]) Next() bool

func (*Cursor[T]) Prev

func (c *Cursor[T]) Prev() bool

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]) Reverse

func (ll *LinkedList[T]) Reverse()

Reverse reverses 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.

Jump to

Keyboard shortcuts

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