2021-10-13 00:23:56 +02:00
|
|
|
package it.cavallium.dbengine.lucene;
|
|
|
|
|
2022-06-30 15:06:10 +02:00
|
|
|
import it.cavallium.dbengine.database.DiscardingCloseable;
|
2021-12-18 21:01:14 +01:00
|
|
|
import it.cavallium.dbengine.database.SafeCloseable;
|
2021-10-13 00:23:56 +02:00
|
|
|
|
2022-06-30 15:06:10 +02:00
|
|
|
public interface PriorityQueue<T> extends ResourceIterable<T>, DiscardingCloseable {
|
2021-10-13 00:23:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an Object to a PriorityQueue in log(size) time. If one tries to add more objects than maxSize from initialize
|
|
|
|
* an {@link ArrayIndexOutOfBoundsException} is thrown.
|
|
|
|
*/
|
|
|
|
void add(T element);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the least element of the PriorityQueue in constant time.
|
|
|
|
*/
|
|
|
|
T top();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes and returns the least element of the PriorityQueue in log(size) time.
|
|
|
|
*/
|
|
|
|
T pop();
|
|
|
|
|
|
|
|
/**
|
2021-10-14 15:55:58 +02:00
|
|
|
* Replace the top of the pq with {@code newTop}
|
2021-10-13 00:23:56 +02:00
|
|
|
*/
|
2022-06-15 18:36:22 +02:00
|
|
|
void replaceTop(T oldTop, T newTop);
|
2021-10-13 00:23:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of elements currently stored in the PriorityQueue.
|
|
|
|
*/
|
|
|
|
long size();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all entries from the PriorityQueue.
|
|
|
|
*/
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an existing element currently stored in the PriorityQueue. Cost is linear with the size of the queue. (A
|
|
|
|
* specialization of PriorityQueue which tracks element positions would provide a constant remove time but the
|
|
|
|
* trade-off would be extra cost to all additions/insertions)
|
|
|
|
*/
|
|
|
|
boolean remove(T element);
|
|
|
|
}
|