linkedlist

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 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 LinkedList

type LinkedList struct {
	// contains filtered or unexported fields
}

Is very much the same as a single linked list, but runs two-way references in each node. Or alternatively the LinkedList can refer to a Map structure to hold indices of each and their next/previous nodes.

func (*LinkedList) Append

func (ll *LinkedList) Append(data interface{}) *LinkedList

Appends a node to the singly linked list

func (*LinkedList) Contains

func (ll *LinkedList) Contains(data interface{}) int

Finds the data in the list and returns the index it was found at. If the node cannot be found, returns -1.

func (*LinkedList) Count

func (ll *LinkedList) Count() int

Counts the amount of linked nodes and returns the count.

func (*LinkedList) Get

func (ll *LinkedList) Get(index int) (*LinkedListNode, error)

Find a node by 'index', index simply refers to how many nodes we must iterate through before finding the desired now If the node cannot be found, will return nil

func (*LinkedList) Prepend

func (ll *LinkedList) Prepend(data interface{}) *LinkedList

Prepends a node to the singly linked list

func (*LinkedList) Remove

func (ll *LinkedList) Remove(index int) bool

Removes a node from the list at specified index Note, each previous index for an node will be -1. Returns a bool whether or not a node was removed

type LinkedListNode

type LinkedListNode struct {
	NextNode     *LinkedListNode
	PreviousNode *LinkedListNode
	Value        interface{}
}

Jump to

Keyboard shortcuts

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