mirror of
https://github.com/duke-git/lancet.git
synced 2025-11-03 03:13:32 +08:00
feat: add IsEmpty and IsFull for PriorityQueue
This commit is contained in:
@@ -19,3 +19,13 @@ func NewPriorityQueue[T any](capacity int, comparator lancetconstraints.Comparat
|
||||
comparator: comparator,
|
||||
}
|
||||
}
|
||||
|
||||
// IsEmpty checks if the queue is empty or not
|
||||
func (q *PriorityQueue[T]) IsEmpty() bool {
|
||||
return q.size == 0
|
||||
}
|
||||
|
||||
// IsFull checks if the queue capacity is full or not
|
||||
func (q *PriorityQueue[T]) IsFull() bool {
|
||||
return q.size == len(q.items)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user