Documentation ¶
Index ¶
- type BitSet32
- type BucketQueue
- type Deque
- type FlatGrid
- func (f *FlatGrid[T]) Clear()
- func (f *FlatGrid[T]) Clone() FlatGrid[T]
- func (f *FlatGrid[T]) Coords(idx int) (x, y int)
- func (f *FlatGrid[T]) Get(x, y int) T
- func (f *FlatGrid[T]) InBounds(x, y int) bool
- func (f *FlatGrid[T]) Index(x, y int) int
- func (f *FlatGrid[T]) Set(x, y int, t T)
- func (f *FlatGrid[T]) Size() (width, height int)
- type Heap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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]) PeekBack ¶
func (d *Deque[T]) PeekBack() T
PeekBack returns the last element without removing it
type FlatGrid ¶
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 ¶
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