util

package
v0.0.0-...-b76af60 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

a simple implementation of a priority queue based on golangs heap structure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Buffer

func Buffer(in <-chan int, out chan<- int)

Buffer provides an unbounded buffer between in and out. Buffer exits when in is closed and all items in the buffer have been sent to out, at which point it closes out.

Types

type BitArray

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

This struct implements a BitArray with variable bit width. Values in BitArray can use either 1, 2, 4 or 8 bits (respectively 8, 4, 2 or 1 values can be represented using a single byte).

func NewBitArray

func NewBitArray(capacity uint32, bitsPerWord byte) *BitArray

Creates a new BitArray that can hold 'capacity' many words of size bitsPerWord

func (*BitArray) BitsPerWord

func (b *BitArray) BitsPerWord() byte

func (*BitArray) Bytes

func (b *BitArray) Bytes() []byte

func (*BitArray) GetB

func (b *BitArray) GetB(pos uint32) byte

Returns the value stored at position pos

func (*BitArray) GetBytes

func (b *BitArray) GetBytes(pos uint32, n uint32) []byte

Returns all values between pos and pos+n (to fetch a complete search state)

func (*BitArray) Len

func (b *BitArray) Len() int

func (*BitArray) SetB

func (b *BitArray) SetB(pos uint32, val byte)

Sets the value at pos to val

func (*BitArray) SetBytes

func (b *BitArray) SetBytes(pos uint32, bs []byte)

Sets multiple bytes (to insert a search state into BitArray)

type Item

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

type PriorityQueue

type PriorityQueue []*Item

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

remove and return item with highest priority

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

add new item to the priority queue

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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