heaputil

package
v0.0.0-...-7b47597 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByEndTime

type ByEndTime []ScheduledItem

ByEndTime implements sort.Interface based on the EndTime

func (ByEndTime) Len

func (a ByEndTime) Len() int

func (ByEndTime) Less

func (a ByEndTime) Less(i, j int) bool

func (ByEndTime) Swap

func (a ByEndTime) Swap(i, j int)

type ByEndingTime

type ByEndingTime []ExternalItem

ByEndingTime implements sort.Interface based on the EndingTime

func (ByEndingTime) Len

func (a ByEndingTime) Len() int

func (ByEndingTime) Less

func (a ByEndingTime) Less(i, j int) bool

func (ByEndingTime) Swap

func (a ByEndingTime) Swap(i, j int)

type ExternalItem

type ExternalItem struct {
	Value      string // The value of the item; arbitrary.
	Duration   int    // The priority of the item in the Max Heap.
	EndingTime int    // Used for sorting items by lowest ending item
}

ExternalItem is sent from the caller for scheduling.

type Item

type Item struct {
	Value    string // The value of the item; arbitrary.
	Priority int    // The priority of the item in the queue.
	// contains filtered or unexported fields
}

Item is something we manage in a priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

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

func (*PriorityQueue) Peek

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

Peek returns the top item from priority queue

func (*PriorityQueue) Pop

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

Pop pops an item from priority queue

func (*PriorityQueue) Push

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

Push pushes an item into priority queue. Items are ordered in a priority queue always.

func (PriorityQueue) Swap

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

type ScheduledItem

type ScheduledItem struct {
	Value    string
	Start    int
	Duration int
	End      int
}

ScheduledItem is the scheduled item post processing

func ScheduleItems

func ScheduleItems(items []ExternalItem) []ScheduledItem

ScheduleItems provides a schedule of maximum items that can be taken contiguously The "item" can be a course or an event

Jump to

Keyboard shortcuts

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