-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.d.ts
More file actions
90 lines (70 loc) · 2.44 KB
/
Copy pathqueue.d.ts
File metadata and controls
90 lines (70 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/** FIFO queue backed by a value list. */
export class Queue<V = unknown> {
/** Number of elements in the queue. */
size: number;
/**
* @param underlyingList - A pre-existing value list to adopt, or a list class to instantiate.
*/
constructor(underlyingList?: object | (new () => object));
/** Whether the queue has no elements. */
get isEmpty(): boolean;
/** The front element without removing it, or `undefined` if empty. */
get top(): V | undefined;
/** The front element without removing it, or `undefined` if empty. An alias of `top`. */
get front(): V | undefined;
/** Alias for {@link top}. */
peek(): V | undefined;
/**
* Add a value to the back of the queue.
* @param value - Value to enqueue.
* @returns `this` for chaining.
*/
add(value: V): this;
/** Alias for {@link add}. */
push(value: V): this;
/** Alias for {@link add}. */
pushBack(value: V): this;
/** Alias for {@link add}. */
enqueue(value: V): this;
/**
* Remove and return the front value.
* @returns The front value, or `undefined` if empty.
*/
remove(): V | undefined;
/** Alias for {@link remove}. */
pop(): V | undefined;
/** Alias for {@link remove}. */
popFront(): V | undefined;
/** Alias for {@link remove}. */
dequeue(): V | undefined;
/**
* Add multiple values to the back of the queue.
* @param values - Iterable of values.
* @returns `this` for chaining.
*/
addValues(values: Iterable<V>): this;
/** Alias for {@link addValues}. */
pushValues(values: Iterable<V>): this;
/**
* Remove all elements.
* @returns `this` for chaining.
*/
clear(): this;
/** Iterate over values from front to back. */
[Symbol.iterator](): IterableIterator<V>;
/**
* Iterate over values from back to front. Delegates to the underlying list's
* `getReverseIterator` if it has one (DLL-based lists do; SLL-based lists don't),
* otherwise returns `undefined`.
* @returns An iterable iterator, or `undefined` when the underlying list does not support reverse iteration.
*/
getReverseIterator(): IterableIterator<V> | undefined;
/**
* Build a Queue from an iterable.
* @param values - Iterable of values to enqueue.
* @param underlyingList - A pre-existing value list to adopt, or a list class to instantiate.
* @returns A new Queue.
*/
static from<V = unknown>(values: Iterable<V>, underlyingList?: object | (new () => object)): Queue<V>;
}
export default Queue;