gost

package
v0.0.0-...-e199811 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MinHeapContents

type MinHeapContents []*priorityItem

heapContents implements heap.Interface and holds priorityItems.

func (MinHeapContents) Len

func (mhc MinHeapContents) Len() int

len returns the length of heapContents.

func (MinHeapContents) Less

func (mhc MinHeapContents) Less(i, j int) bool

Less responds whether item in index i should be sorted before j (or will take "Less" time to dequeue). If two contents have the same priority, the response will be false as it strictly checks for higher priority.

func (*MinHeapContents) Pop

func (mhc *MinHeapContents) Pop() interface{}

Dequeue removes the first value to be dequeued from heapContents.

func (*MinHeapContents) Push

func (mhc *MinHeapContents) Push(x interface{})

Enqueue expects an element x of type *priorityItem and appends it to heapContents.

func (MinHeapContents) Swap

func (mhc MinHeapContents) Swap(i, j int)

Swap switches places between both priorityItems in the designated indices.

type MinPriorityQueue

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

MinPriorityQueue implements a heap-based priority queue, only exposing methods Enqueue() and Dequeue() for simplicity. Inverse priority means that items with lower priority are dequeued faster than higher priority ones. This implementation uses FIFO order as tiebreaker when elements have the same priority.

func NewMinPriorityQueue

func NewMinPriorityQueue() (pq *MinPriorityQueue)

NewMinPriorityQueue initializes the heap-based priority queue and returns the instance.

func (*MinPriorityQueue) Dequeue

func (pq *MinPriorityQueue) Dequeue() interface{}

Dequeue removes the item in the MinPriorityQueue with the lowest priority, or insertion order when there's no lower priority contents. If the queue is empty, returns nil.

func (*MinPriorityQueue) Enqueue

func (pq *MinPriorityQueue) Enqueue(item interface{}, priority float64)

Enqueue adds an interface item and its priority into the MinPriorityQueue.

func (*MinPriorityQueue) Size

func (pq *MinPriorityQueue) Size() int

Size returns the size of the MinPriorityQueue.

type NodeQueue

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

NodeQueue is a single-linked contents backed implementation of queues. It takes any interface{} and allows:

- Enqueuing: inserting an item into the last position of the queue.

- De-queuing: retrieving the first item in the queue.

Note that the implementation is NOT thread-safe.

func (*NodeQueue) Dequeue

func (queue *NodeQueue) Dequeue() interface{}

Dequeue the head node of the queue. Returns the data or nil if empty.

func (*NodeQueue) Enqueue

func (queue *NodeQueue) Enqueue(data interface{})

Enqueue a new Node containing data (interface{}) to the tail of the queue.

func (*NodeQueue) Size

func (queue *NodeQueue) Size() int

Size returns the length of the NodeQueue.

type PriorityQueue

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

PriorityQueue implements a heap-based priority queue, only exposing methods Enqueue() and Dequeue() for simplicity. This implementation uses FIFO order as tiebreaker when elements have the same priority.

func NewPriorityQueue

func NewPriorityQueue() (pq *PriorityQueue)

NewPriorityQueue initializes the heap-based priority queue and returns the instance.

func (*PriorityQueue) Dequeue

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

Dequeue removes the item in the PriorityQueue with the highest priority, or insertion order when there's no higher priority contents. If the queue is empty, returns nil.

func (*PriorityQueue) Enqueue

func (pq *PriorityQueue) Enqueue(item interface{}, priority float64)

Enqueue adds an interface item and its priority into the PriorityQueue.

func (*PriorityQueue) Size

func (pq *PriorityQueue) Size() int

Size returns the size of the PriorityQueue.

type Queue

type Queue interface {
	Dequeue() interface{}
	Enqueue(data interface{})
	Size() int
}

type SliceQueue

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

SliceQueue is a slice-backed implementation of queues. It takes any type implementing interface{} and allows:

- Enqueuing: inserting an item into the last position of the queue.

- De-queuing: retrieving the first item in the queue.

Note that the implementation is NOT thread-safe.

func NewQueue

func NewQueue(cap int) *SliceQueue

NewQueue creates a new queue with initial len() zero and capacity cap.

func (*SliceQueue) Dequeue

func (queue *SliceQueue) Dequeue() interface{}

Dequeue the head node of the queue. Returns the data or nil if empty.

func (*SliceQueue) Enqueue

func (queue *SliceQueue) Enqueue(data interface{})

Enqueue a new node containing data (interface{}) to the tail of the queue.

func (*SliceQueue) Size

func (queue *SliceQueue) Size() int

Size returns the length of the queue's underlying slice.

Jump to

Keyboard shortcuts

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