Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ElementHolder ¶
type ElementHolder[T any] struct { // contains filtered or unexported fields }
ElementHolder holds elements of the PriorityQueue
func (*ElementHolder[T]) Len ¶
func (h *ElementHolder[T]) Len() int
Len returns the amount of elements in ElementHolder
func (*ElementHolder[T]) Less ¶
func (h *ElementHolder[T]) Less(i, j int) bool
Len compare two elements at position i and j , and returns true if elements[i] < elements[j]
func (*ElementHolder[T]) Pop ¶
func (h *ElementHolder[T]) Pop() T
Pop pops an element from the ElementHolder
func (*ElementHolder[T]) Push ¶
func (h *ElementHolder[T]) Push(element T)
Push pushes an element to the ElementHolder
func (*ElementHolder[T]) Swap ¶
func (h *ElementHolder[T]) Swap(i, j int)
Swap swaps two elements at position i and j
type Option ¶
type Option func(option *Options)
Option is a function type used to set Options
func WithGoroutineSafe ¶
func WithGoroutineSafe() Option
WithGoroutineSafe is used to set the PriorityQueue goroutine-safe
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds PriorityQueue's options
type PriorityQueue ¶
type PriorityQueue[T any] struct { // contains filtered or unexported fields }
PriorityQueue is an implementation of priority queue
func New ¶
func New[T any](cmp comparator.Comparator[T], opts ...Option) *PriorityQueue[T]
New creates a PriorityQueue
func (*PriorityQueue[T]) Empty ¶
func (q *PriorityQueue[T]) Empty() bool
Empty returns true if the PriorityQueue is empty, otherwise returns false
func (*PriorityQueue[T]) Pop ¶
func (q *PriorityQueue[T]) Pop() T
Pop pops an element from the PriorityQueue
func (*PriorityQueue[T]) Push ¶
func (q *PriorityQueue[T]) Push(e T)
Push pushes an element to the PriorityQueue
func (*PriorityQueue[T]) Size ¶ added in v1.0.1
func (q *PriorityQueue[T]) Size() int
Size returns the amount of elements in the queue
func (*PriorityQueue[T]) Top ¶
func (q *PriorityQueue[T]) Top() T
Top returns the top element in the PriorityQueue