priority_queue

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package priority_queue implement a thread safe priority powered by "container/heap"

Index

Constants

View Source
const (
	Default_PQueue_Size = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PQueue

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

PQueue implement a priority queue

func NewPQueue

func NewPQueue(size int) *PQueue

return a fix size priority queue

func (*PQueue) Cap

func (pq *PQueue) Cap() int

return queue size

func (*PQueue) IsEmpty

func (pq *PQueue) IsEmpty() bool

check if queue is empty

func (*PQueue) IsFull

func (pq *PQueue) IsFull() bool

check if queue if full(reach max capacity)

func (PQueue) Len

func (pq PQueue) Len() int

below is used to implement internal interface ref:https://godoc.org/container/heap shall not use it directly

func (*PQueue) Length

func (pq *PQueue) Length() int

return queue size

func (PQueue) Less

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

func (*PQueue) Pop

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

func (*PQueue) PopItem

func (pq *PQueue) PopItem() (interface{}, bool)

Pop a item from priority queue

func (*PQueue) Push

func (pq *PQueue) Push(v interface{})

func (*PQueue) PushItem

func (pq *PQueue) PushItem(v *Payload) (evicted bool)

Push a item into priority queue

func (PQueue) Swap

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

type Payload

type Payload struct {
	Value    interface{}
	Priority int
	// contains filtered or unexported fields
}

payload holds the data in priority queue

Jump to

Keyboard shortcuts

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