structures

package
v0.0.0-...-aa75ebd Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet32

type BitSet32[T ~int32 | ~uint32] [b32L2Size]*level2

func (*BitSet32[T]) Clear

func (b *BitSet32[T]) Clear(t T)

func (*BitSet32[T]) Clone

func (b *BitSet32[T]) Clone() *BitSet32[T]

func (*BitSet32[T]) Has

func (b *BitSet32[T]) Has(t T) bool

func (*BitSet32[T]) Set

func (b *BitSet32[T]) Set(t T)

type BucketQueue

type BucketQueue[T comparable] struct {
	// contains filtered or unexported fields
}

BucketQueue implements a priority queue using a doubly linked list where each node contains a list of items with a given priority. Lower priority value items are higher priority i.e. are returned by Pop first. Items with the same priority may be returned in any order.

func (*BucketQueue[T]) IsEmpty

func (b *BucketQueue[T]) IsEmpty() bool

IsEmpty returns if the queue contains zero items

func (*BucketQueue[T]) Peek

func (b *BucketQueue[T]) Peek() T

Peek returns (without removing) the next item which would be returned by Pop

func (*BucketQueue[T]) Pop

func (b *BucketQueue[T]) Pop() T

Pop returns and removes an item with the lowest priority value

func (*BucketQueue[T]) Push

func (b *BucketQueue[T]) Push(t T, priority int)

Push adds the given item with the given priority to the queue Lower priority values are returned by Pop first

func (*BucketQueue[T]) String

func (b *BucketQueue[T]) String() string

String returns a pretty printed string representing the queue

func (*BucketQueue[T]) ToSlice

func (b *BucketQueue[T]) ToSlice() []T

ToSlice returns a slice of the items currently in the queue, sorted by priority. Intended for debugging only

type Deque

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

Deque implements a double ended queue ("deque") using a circular buffer. This enables it to be used as a queue or stack, but is mainly beneficial for queue usage as it avoids reducing the slice's capacity when popping elements from the front

func (*Deque[T]) IsEmpty

func (d *Deque[T]) IsEmpty() bool

func (*Deque[T]) Len

func (d *Deque[T]) Len() int

func (*Deque[T]) PeekBack

func (d *Deque[T]) PeekBack() T

PeekBack returns the last element without removing it

func (*Deque[T]) PeekFront

func (d *Deque[T]) PeekFront() T

PeekFront returns the first element without removing it

func (*Deque[T]) PopBack

func (d *Deque[T]) PopBack() T

PopBack removes the last element

func (*Deque[T]) PopFront

func (d *Deque[T]) PopFront() T

PopFront removes the first element

func (*Deque[T]) PushBack

func (d *Deque[T]) PushBack(t T)

PushBack adds an element at the end

func (*Deque[T]) PushFront

func (d *Deque[T]) PushFront(t T)

PushFront adds an element at the front

type FlatGrid

type FlatGrid[T any] struct {
	S             []T
	Width, Height int
}

FlatGrid implements a generic 2d grid with a flat backing slice, which is exported for fast access & modification. This is ideal for simple grids where the minimum coordinate is (0, 0) and automatic resizing is not needed. Methods are simple and should be inlined in almost all cases.

vec.Grid offers more functionality (including automatic resizing & bounds checks) at the cost of more overhead for each access/modification.

func NewFlatGrid

func NewFlatGrid[T any](width, height int) *FlatGrid[T]

func (*FlatGrid[T]) Clear

func (f *FlatGrid[T]) Clear()

func (*FlatGrid[T]) Clone

func (f *FlatGrid[T]) Clone() FlatGrid[T]

func (*FlatGrid[T]) Coords

func (f *FlatGrid[T]) Coords(idx int) (x, y int)

func (*FlatGrid[T]) Get

func (f *FlatGrid[T]) Get(x, y int) T

func (*FlatGrid[T]) InBounds

func (f *FlatGrid[T]) InBounds(x, y int) bool

func (*FlatGrid[T]) Index

func (f *FlatGrid[T]) Index(x, y int) int

func (*FlatGrid[T]) Set

func (f *FlatGrid[T]) Set(x, y int, t T)

func (*FlatGrid[T]) Size

func (f *FlatGrid[T]) Size() (width, height int)

Size is a helper function which returns width & height, meant to be used when creating a new blank grid with the same size as an existing one

structures.NewFlatGrid(existing.Size())

type Heap

type Heap[T comparable] struct {
	LessThan func(a, b T) bool
	// contains filtered or unexported fields
}

Heap implements a binary heap using generics. A LessThan function must be set when creating a Heap

func (*Heap[T]) IsEmpty

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

func (*Heap[T]) Len

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

func (*Heap[T]) Peek

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

func (*Heap[T]) Pop

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

func (*Heap[T]) Push

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

Jump to

Keyboard shortcuts

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