/** * @since 2.0.0 */ import type * as Chunk from "./Chunk.js" import * as internal from "./internal/stm/tPriorityQueue.js" import type * as Option from "./Option.js" import type * as Order from "./Order.js" import type { Predicate } from "./Predicate.js" import type * as SortedMap from "./SortedMap.js" import type * as STM from "./STM.js" import type * as TRef from "./TRef.js" import type * as Types from "./Types.js" /** * @since 2.0.0 * @category symbols */ export const TPriorityQueueTypeId: unique symbol = internal.TPriorityQueueTypeId /** * @since 2.0.0 * @category symbols */ export type TPriorityQueueTypeId = typeof TPriorityQueueTypeId /** * A `TPriorityQueue` contains values of type `A` that an `Order` is defined * on. Unlike a `TQueue`, `take` returns the highest priority value (the value * that is first in the specified ordering) as opposed to the first value * offered to the queue. The ordering that elements with the same priority will * be taken from the queue is not guaranteed. * * @since 2.0.0 * @category models */ export interface TPriorityQueue extends TPriorityQueue.Variance {} /** * @internal * @since 2.0.0 */ export interface TPriorityQueue { /** @internal */ readonly ref: TRef.TRef]>> } /** * @since 2.0.0 */ export declare namespace TPriorityQueue { /** * @since 2.0.0 * @category models */ export interface Variance { readonly [TPriorityQueueTypeId]: { readonly _A: Types.Invariant } } } /** * Constructs a new empty `TPriorityQueue` with the specified `Order`. * * @since 2.0.0 * @category constructors */ export const empty: (order: Order.Order) => STM.STM> = internal.empty /** * Creates a new `TPriorityQueue` from an iterable collection of values. * * @since 2.0.0 * @category constructors */ export const fromIterable: ( order: Order.Order ) => (iterable: Iterable) => STM.STM> = internal.fromIterable /** * Checks whether the queue is empty. * * @since 2.0.0 * @category getters */ export const isEmpty: (self: TPriorityQueue) => STM.STM = internal.isEmpty /** * Checks whether the queue is not empty. * * @since 2.0.0 * @category getters */ export const isNonEmpty: (self: TPriorityQueue) => STM.STM = internal.isNonEmpty /** * Makes a new `TPriorityQueue` that is initialized with specified values. * * @since 2.0.0 * @category constructors */ export const make: (order: Order.Order) => (...elements: Array) => STM.STM> = internal.make /** * Offers the specified value to the queue. * * @since 2.0.0 * @category mutations */ export const offer: { /** * Offers the specified value to the queue. * * @since 2.0.0 * @category mutations */ (value: A): (self: TPriorityQueue) => STM.STM /** * Offers the specified value to the queue. * * @since 2.0.0 * @category mutations */ (self: TPriorityQueue, value: A): STM.STM } = internal.offer /** * Offers all of the elements in the specified collection to the queue. * * @since 2.0.0 * @category mutations */ export const offerAll: { /** * Offers all of the elements in the specified collection to the queue. * * @since 2.0.0 * @category mutations */ (values: Iterable): (self: TPriorityQueue) => STM.STM /** * Offers all of the elements in the specified collection to the queue. * * @since 2.0.0 * @category mutations */ (self: TPriorityQueue, values: Iterable): STM.STM } = internal.offerAll /** * Peeks at the first value in the queue without removing it, retrying until a * value is in the queue. * * @since 2.0.0 * @category getters */ export const peek: (self: TPriorityQueue) => STM.STM = internal.peek /** * Peeks at the first value in the queue without removing it, returning `None` * if there is not a value in the queue. * * @since 2.0.0 * @category getters */ export const peekOption: (self: TPriorityQueue) => STM.STM> = internal.peekOption /** * Removes all elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ export const removeIf: { /** * Removes all elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ (predicate: Predicate): (self: TPriorityQueue) => STM.STM /** * Removes all elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ (self: TPriorityQueue, predicate: Predicate): STM.STM } = internal.removeIf /** * Retains only elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ export const retainIf: { /** * Retains only elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ (predicate: Predicate): (self: TPriorityQueue) => STM.STM /** * Retains only elements from the queue matching the specified predicate. * * @since 2.0.0 * @category getters */ (self: TPriorityQueue, predicate: Predicate): STM.STM } = internal.retainIf /** * Returns the size of the queue. * * @since 2.0.0 * @category getters */ export const size: (self: TPriorityQueue) => STM.STM = internal.size /** * Takes a value from the queue, retrying until a value is in the queue. * * @since 2.0.0 * @category mutations */ export const take: (self: TPriorityQueue) => STM.STM = internal.take /** * Takes all values from the queue. * * @since 2.0.0 * @category mutations */ export const takeAll: (self: TPriorityQueue) => STM.STM> = internal.takeAll /** * Takes a value from the queue, returning `None` if there is not a value in * the queue. * * @since 2.0.0 * @category mutations */ export const takeOption: (self: TPriorityQueue) => STM.STM> = internal.takeOption /** * Takes up to the specified maximum number of elements from the queue. * * @since 2.0.0 * @category mutations */ export const takeUpTo: { /** * Takes up to the specified maximum number of elements from the queue. * * @since 2.0.0 * @category mutations */ (n: number): (self: TPriorityQueue) => STM.STM> /** * Takes up to the specified maximum number of elements from the queue. * * @since 2.0.0 * @category mutations */ (self: TPriorityQueue, n: number): STM.STM> } = internal.takeUpTo /** * Collects all values into a `Chunk`. * * @since 2.0.0 * @category destructors */ export const toChunk: (self: TPriorityQueue) => STM.STM> = internal.toChunk /** * Collects all values into an array. * * @since 2.0.0 * @category destructors */ export const toArray: (self: TPriorityQueue) => STM.STM> = internal.toArray