-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathIterator.ts
More file actions
executable file
·86 lines (75 loc) · 1.96 KB
/
Iterator.ts
File metadata and controls
executable file
·86 lines (75 loc) · 1.96 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
/**
* Interface for navigating through a collection, where backward navigation is optional.
*
* @interface
* @template T - type of elements in the collection.
* @since 1.0.0
* @version 1.0.0
*/
export interface Iterator<T> {
/**
* Gets the index of the current position in the collection.
*
* @returns The current index.
*/
index?(): number;
/**
* Moves the iterator to the specified index.
*
* @param {number} index - the index to move to.
* @throws {@link RangeError} If the index is out of bounds.
*/
moveTo?(index: number): void;
/**
* Moves to and retrieves the next element in the collection.
*
* @returns {T} The next element.
* @throws {@link Error} If there is no next element.
*/
next(): T;
/**
* Gets the index of the next position in the collection.
*
* @returns {number} The index of the next element.
*/
nextIndex?(): number;
/**
* Moves to and retrieves the previous element in the collection.
*
* @returns {T} The previous element.
* @throws {@link Error} If there is no previous element.
*/
previous?(): T;
/**
* Gets the index of the previous position in the collection.
*
* @returns {number} The index of the previous element.
*/
previousIndex?(): number;
/**
* Gets the total number of elements in the collection.
*
* @returns {number} The total element count.
*/
size?(): number;
/**
* Checks if a next element exists in the collection.
*
* @returns {boolean} `true` if there is a next element, otherwise `false`.
*/
hasNext(): boolean;
/**
* Checks if a previous element exists in the collection.
*
* @returns {boolean} `true` if there is a previous element, otherwise `false`.
*/
hasPrevious?(): boolean;
/**
* Resets the iterator to the last element of the collection.
*/
toEnd?(): void;
/**
* Resets the iterator to the first element of the collection.
*/
toStart?(): void;
}