{"modulePath":"github.com/Evolution404/simcore","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package prque\n\nPackage prque implements a priority queue data structure supporting arbitrary value types and int64 priorities.\n\nIf you would like to use a min-priority queue, simply negate the priorities.\n\nInternally the queue is based on the standard heap package working on a sortable version of the block based stack.\n\n## Types\n\n```go\ntype LazyQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nLazyQueue is a priority queue data structure where priorities can change over time and are only evaluated on demand. Two callbacks are required:\n\n  - priority evaluates the actual priority of an item\n  - maxPriority gives an upper estimate for the priority in any moment between now and the given absolute time\n\nIf the upper estimate is exceeded then Update should be called for that item. A global Refresh function should also be called periodically.\n\n```go\nfunc NewLazyQueue(setIndex SetIndexCallback, priority PriorityCallback, maxPriority MaxPriorityCallback, clock mclock.Clock, refreshPeriod time.Duration) *LazyQueue\n```\nNewLazyQueue creates a new lazy queue\n\n```go\nfunc (q *LazyQueue) Empty() bool\n```\nEmpty checks whether the priority queue is empty.\n\n```go\nfunc (q *LazyQueue) MultiPop(callback func(data interface{}, priority int64) bool)\n```\nMultiPop pops multiple items from the queue and is more efficient than calling Pop multiple times. Popped items are passed to the callback. MultiPop returns when the callback returns false or there are no more items to pop.\n\n```go\nfunc (q *LazyQueue) Pop() (interface{}, int64)\n```\nPop removes and returns the item with the greatest actual priority\n\n```go\nfunc (q *LazyQueue) PopItem() interface{}\n```\nPopItem pops the item from the queue only, dropping the associated priority value.\n\n```go\nfunc (q *LazyQueue) Push(data interface{})\n```\nPush adds an item to the queue\n\n```go\nfunc (q *LazyQueue) Refresh()\n```\nRefresh performs queue re-evaluation if necessary\n\n```go\nfunc (q *LazyQueue) Remove(index int) interface{}\n```\nRemove removes removes the item with the given index.\n\n```go\nfunc (q *LazyQueue) Reset()\n```\nReset clears the contents of the queue\n\n```go\nfunc (q *LazyQueue) Size() int\n```\nSize returns the number of items in the priority queue.\n\n```go\nfunc (q *LazyQueue) Update(index int)\n```\nUpdate updates the upper priority estimate for the item with the given queue index\n\n```go\ntype MaxPriorityCallback func(data interface{}, until mclock.AbsTime) int64 // estimated maximum priority callback\n\n```\n\n```go\ntype PriorityCallback func(data interface{}) int64 // actual priority callback\n\n```\n\n```go\ntype Prque struct {\n\t// contains filtered or unexported fields\n}\n```\nPriority queue data structure.\n\n```go\nfunc New(setIndex SetIndexCallback) *Prque\n```\nNew creates a new priority queue.\n\n```go\nfunc NewWrapAround(setIndex SetIndexCallback) *Prque\n```\nNewWrapAround creates a new priority queue with wrap-around priority handling.\n\n```go\nfunc (p *Prque) Empty() bool\n```\nChecks whether the priority queue is empty.\n\n```go\nfunc (p *Prque) Peek() (interface{}, int64)\n```\nPeek returns the value with the greatest priority but does not pop it off.\n\n```go\nfunc (p *Prque) Pop() (interface{}, int64)\n```\nPops the value with the greates priority off the stack and returns it. Currently no shrinking is done.\n\n```go\nfunc (p *Prque) PopItem() interface{}\n```\nPops only the item from the queue, dropping the associated priority value.\n\n```go\nfunc (p *Prque) Push(data interface{}, priority int64)\n```\nPushes a value with a given priority into the queue, expanding if necessary.\n\n```go\nfunc (p *Prque) Remove(i int) interface{}\n```\nRemove removes the element with the given index.\n\n```go\nfunc (p *Prque) Reset()\n```\nClears the contents of the priority queue.\n\n```go\nfunc (p *Prque) Size() int\n```\nReturns the number of element in the priority queue.\n\n```go\ntype SetIndexCallback func(data interface{}, index int)\n```\nSetIndexCallback is called when the element is moved to a new index. Providing SetIndexCallback is optional, it is needed only if the application needs to delete elements other than the top one.\n\n","path":"github.com/Evolution404/simcore/common/prque","name":"prque","synopsis":"Package prque implements a priority queue data structure supporting arbitrary value types and int64 priorities.","isRedistributable":true}
