goap-oriented
Version:
A TypeScript implementation of Goal-Oriented Action Planning
31 lines (30 loc) • 1.13 kB
TypeScript
/**
* A priority queue implementation that maintains elements in a sorted order based on a comparison function.
* @template T The type of elements stored in the queue
*/
export declare class PriorityQueue<T> {
private items;
private compare;
/**
* Creates a new PriorityQueue instance.
* @param compareFunction A function that defines the priority between two elements.
* Should return a negative number if a has higher priority than b,
* zero if they have equal priority, or a positive number if b has higher priority than a.
*/
constructor(compareFunction: (a: T, b: T) => number);
/**
* Adds an item to the queue and sorts it based on priority.
* @param item The item to add to the queue
*/
enqueue(item: T): void;
/**
* Removes and returns the highest priority item from the queue.
* @returns The highest priority item, or undefined if the queue is empty
*/
dequeue(): T | undefined;
/**
* Checks if the queue is empty.
* @returns true if the queue contains no elements, false otherwise
*/
isEmpty(): boolean;
}