ds

package
v0.0.0-...-884cce2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

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

func NewHeap

func NewHeap[T any](compare func(a, b T) bool) *Heap[T]

func (*Heap[T]) Clear

func (h *Heap[T]) Clear()

func (*Heap[T]) Empty

func (h *Heap[T]) Empty() bool

func (*Heap[T]) Len

func (h *Heap[T]) Len() int

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() T

func (*Heap[T]) Push

func (h *Heap[T]) Push(v T)

type PriorityQueue

type PriorityQueue[T any, P comparable] struct {
	// contains filtered or unexported fields
}

PriorityQueue will pop items with the highest or lowest priority depending on compare.

func NewPriorityQueue

func NewPriorityQueue[T any, P comparable](compare func(a, b P) bool) *PriorityQueue[T, P]

NewPriorityQueue creates a heap that is sorted by priority.

func (*PriorityQueue[T, P]) Clear

func (h *PriorityQueue[T, P]) Clear()

Clear removes all items from the queue.

func (*PriorityQueue[T, P]) Empty

func (h *PriorityQueue[T, P]) Empty() bool

Empty returns true if the queue is empty.

func (*PriorityQueue[T, P]) Len

func (h *PriorityQueue[T, P]) Len() int

Len returns the number of items in the queue.

func (*PriorityQueue[T, P]) Pop

func (h *PriorityQueue[T, P]) Pop() T

Pop removes the item with the highest or lowest priority depending on compare.

func (*PriorityQueue[T, P]) Push

func (h *PriorityQueue[T, P]) Push(v T, priority P)

Push adds an item to the queue with the given priority.

type Queue

type Queue[T any] []T

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

Clear empties the queue but retains the memory

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

Empty returns true if the queue is empty

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

Pop removes the first element and returns it

func (*Queue[T]) Put

func (q *Queue[T]) Put(n T) *Queue[T]

Put adds node to the end

type Stack

type Stack[T any] []T

Stack is First In Last Out

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(node T)

Jump to

Keyboard shortcuts

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