@cute-dw/core
Version:
This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need
25 lines (24 loc) • 1.34 kB
TypeScript
import { Element } from "./Collection";
import { ImmutableQueue, Queue } from "./Queue";
/**
* A linear immutable collection that supports element inspection and extraction at the both ends of the `Queue`
*/
export interface ImmutableDeque<T> extends ImmutableQueue<T> {
/** Retrieves, but does not remove, the first element of this list, or returns _undefined_ if this collection is empty */
peekFirst(): Element<T> | undefined;
/** Retrieves, but does not remove, the last element of this list, or returns _undefined_ if this collection is empty */
peekLast(): Element<T> | undefined;
}
/**
* A linear mutable collection that supports element insertion and removal at the both ends of the `Queue`
*/
export interface Deque<T> extends ImmutableDeque<T>, Queue<T> {
/** Inserts the specified element at the front of this deque */
offerFirst(value: Element<T>): boolean;
/** Inserts the specified element at the end of this deque */
offerLast(value: Element<T>): boolean;
/** Retrieves and removes the first element of this deque, or returns `undefined` if this deque is empty */
pollFirst(): Element<T> | undefined;
/** Retrieves and removes the last element of this deque, or returns `undefined` if this deque is empty */
pollLast(): Element<T> | undefined;
}