README ¶ priorityQueue Priority queue with Generics support Supports only cmp.Ordered types usage var pq Queue[int] pq.Push(2) pq.Push(3) pq.Push(1) for len(pq) != 0 { e = pq.Pop() fmt.Println(e) } type pair struct { x, y int } pq := New[pair](func(i, j pair) bool { return i.x < j.x }) pq.Push(pair{2, 1}) pq.Push(pair{3, -1}) pq.Push(pair{1, 10}) for len(pq) != 0 { e = pq.Pop() fmt.Println(e) } Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type Queue func (q Queue[T]) Len() int func (q Queue[T]) Less(i, j int) bool func (q *Queue[T]) Pop() T func (q *Queue[T]) Push(x T) func (q Queue[T]) Swap(i, j int) type QueueL func New[T any](less func(i, j T) bool) QueueL[T] func (q QueueL[T]) Len() int func (q *QueueL[T]) Pop() (T, bool) func (q *QueueL[T]) Push(x T) func (q QueueL[T]) Swap(i, j int) Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type Queue ¶ type Queue[T cmp.Ordered] []T Queue ... 実装例 func (Queue[T]) Len ¶ func (q Queue[T]) Len() int func (Queue[T]) Less ¶ func (q Queue[T]) Less(i, j int) bool func (*Queue[T]) Pop ¶ func (q *Queue[T]) Pop() T func (*Queue[T]) Push ¶ func (q *Queue[T]) Push(x T) func (Queue[T]) Swap ¶ func (q Queue[T]) Swap(i, j int) type QueueL ¶ added in v0.1.1 type QueueL[T any] struct { // contains filtered or unexported fields } Queue ... 実装例 func New ¶ added in v0.1.1 func New[T any](less func(i, j T) bool) QueueL[T] func (QueueL[T]) Len ¶ added in v0.1.1 func (q QueueL[T]) Len() int func (*QueueL[T]) Pop ¶ added in v0.1.1 func (q *QueueL[T]) Pop() (T, bool) func (*QueueL[T]) Push ¶ added in v0.1.1 func (q *QueueL[T]) Push(x T) func (QueueL[T]) Swap ¶ added in v0.1.1 func (q QueueL[T]) Swap(i, j int) Source Files ¶ View all Source files priorityqueue.gopriorityqueueL.go Click to show internal directories. Click to hide internal directories.