structures

package
v0.0.0-...-07ef3d6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 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 AdjacencyList

type AdjacencyList[T comparable, O constraints.Ordered] interface {
	AddEdge(n1, n2 T, weight O)
	AddUndirectedEdge(n1, n2 T, weight O)
	Edges(node T, fn func(node T, weight O))
	Len() int
}

func NewAdjacencyList

func NewAdjacencyList[T comparable, O constraints.Ordered]() AdjacencyList[T, O]

type BinaryHeap

type BinaryHeap[T any] interface {
	Len() int
	Push(T)
	Pop() T
}

BinaryHeap is a data structure that could speed up hifo calculations

func NewBinaryHeap

func NewBinaryHeap[T any](compFn func(T, T) int) BinaryHeap[T]

type LinkedList

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

func (*LinkedList[T]) Append

func (l *LinkedList[T]) Append(value T)

func (*LinkedList[T]) Copy

func (l *LinkedList[T]) Copy() *LinkedList[T]

func (*LinkedList[T]) ForEach

func (l *LinkedList[T]) ForEach(f func(T))

func (*LinkedList[T]) Len

func (l *LinkedList[T]) Len() int

func (*LinkedList[T]) Reverse

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

func (*LinkedList[T]) ReversedCopy

func (l *LinkedList[T]) ReversedCopy() *LinkedList[T]

func (*LinkedList[T]) Shift

func (l *LinkedList[T]) Shift() (T, bool)

func (*LinkedList[T]) ToQueue

func (l *LinkedList[T]) ToQueue() Queue[T]

func (*LinkedList[T]) ToStack

func (l *LinkedList[T]) ToStack() Stack[T]

func (*LinkedList[T]) Unshift

func (l *LinkedList[T]) Unshift(value T)

type LinkedListNode

type LinkedListNode[T any] struct {
	Value T
	Next  *LinkedListNode[T]
}

type Queue

type Queue[T any] interface {
	Enqueue(T)
	Dequeue() (T, bool)
	Prepend(T)
	Len() int
}

Queue is a convenient data structure used for FIFO

func NewQueue

func NewQueue[T any]() Queue[T]

func NewQueueFromSlice

func NewQueueFromSlice[T any](slc []T) Queue[T]

NewQueueFromSlice accepts a Slice and returns a Queue with the first item in the slice at the beginning of the queue

type Stack

type Stack[T any] interface {
	Push(T)
	Pop() (T, bool)
	Len() int
}

Stack is a convenient data structure used for LIFO

func NewStack

func NewStack[T any]() Stack[T]

func NewStackFromSlice

func NewStackFromSlice[T any](slc []T) Stack[T]

NewStackFromSlice accepts a Slice and returns a Stack with the first item in the slice at the top of the stack

Jump to

Keyboard shortcuts

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