func (pq *priorityQueue) pop() interface{} {
	size := pq.Size()
	if size > 0 {
		val := pq.items[size-1]
		pq.items = pq.items[:(size - 1)]
		return val
	}
	return nil
}
pop removes and returns the last element.
package priorityqueue
import (
	"github.com/ahrtr/gocontainer/queue"
	"github.com/ahrtr/gocontainer/utils"
)
type Interface interface {
	queue.Interface
	WithComparator(c utils.Comparator) Interface
	WithMinHeap(isMinHeap bool) Interface
	Contains(val interface{}) bool
	Remove(val interface{}) bool
}
type priorityQueue struct {
	items     []interface{}
	cmp       utils.Comparator
	isMinHeap bool
}
func New() Interface {
	return &priorityQueue{
		items:     []interface{}{},
		cmp:       nil,
		isMinHeap: true,
	}
}
func (pq *priorityQueue) WithComparator(c utils.Comparator) Interface {
	pq.cmp = c
	return pq
}
func (pq *priorityQueue) WithMinHeap(isMinHeap bool) Interface {
	pq.isMinHeap = isMinHeap
	return pq
}
func (pq *priorityQueue) Size() int { return len(pq.items) }
func (pq *priorityQueue) IsEmpty() bool {
	return pq.Size() == 0
}
func (pq *priorityQueue) Clear() {
	size := pq.Size()
	for i := 0; i < size; i++ {
		pq.items[i] = nil
	}
	pq.items = []interface{}{}
}
func (pq *priorityQueue) Add(vals ...interface{}) {
	for _, v := range vals {
		pq.push(v)
		utils.HeapPostPush(pq.items, pq.isMinHeap, pq.cmp)
	}
}
func (pq *priorityQueue) Peek() interface{} {
	if pq.Size() > 0 {
		return pq.items[0]
	}
	return nil
}
func (pq *priorityQueue) Poll() interface{} {
	if pq.Size() > 0 {
		utils.HeapPrePop(pq.items, pq.isMinHeap, pq.cmp)
		return pq.pop()
	}
	return nil
}
func (pq *priorityQueue) Contains(val interface{}) bool {
	return pq.indexOf(val) >= 0
}
func (pq *priorityQueue) Remove(val interface{}) bool {
	if pq.Size() == 0 {
		return false
	}
	i := pq.indexOf(val)
	if i < 0 {
		return false
	}
	utils.HeapPreRemove(pq.items, i, pq.isMinHeap, pq.cmp)
	pq.pop()
	return true
}
func (pq *priorityQueue) push(val interface{}) {
	pq.items = append(pq.items, val)
}