apply-hooks
Version:
A high-quality & reliable JavaScript Hooks library.
42 lines (41 loc) • 1.1 kB
TypeScript
import { ILinkedList } from '../useLinkedList';
export interface INodeOptions<T = unknown> {
sort: number;
val: T;
}
export interface IEnqueue<T> {
(val: T, sort?: number): boolean;
}
export interface IDequeue<T> {
(): T | boolean;
}
export interface IFront<T> {
(): T | boolean;
}
export interface IIsEmpty {
(): boolean;
}
export interface ISize {
(): number;
}
export interface IToString {
(splitSign: string): string;
}
/**
* enqueue 队尾添加一个值
* dequeue 移除队首的第一个值 并返回该值
* front 返回队列中第一个元素 队列的结构不做任何修改
* isEmpty 判断队列是否为空
* size 表示队列中个数多少
* toString 表示队列中的内容以字符串形式返回
*/
export declare type IConstructorField<T, K extends keyof ILinkedList<T>> = Pick<ILinkedList<INodeOptions<T>>, K>[K];
declare const usePriorityQueue: <T>() => {
enqueue: IEnqueue<T>;
dequeue: IDequeue<T>;
front: IFront<T>;
isEmpty: IIsEmpty;
getSize: ISize;
toString: IToString;
};
export default usePriorityQueue;