data-structure-typed 2.5.3 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/.github/workflows/ci.yml +7 -2
  2. package/.github/workflows/release-package.yml +9 -2
  3. package/.husky/pre-commit +3 -0
  4. package/CHANGELOG.md +1 -1
  5. package/MIGRATION.md +48 -0
  6. package/README.md +20 -2
  7. package/README_CN.md +20 -2
  8. package/SPECIFICATION.md +24 -0
  9. package/SPECIFICATION.zh-CN.md +24 -0
  10. package/dist/cjs/binary-tree.cjs +1897 -19
  11. package/dist/cjs/graph.cjs +174 -0
  12. package/dist/cjs/hash.cjs +33 -0
  13. package/dist/cjs/heap.cjs +71 -0
  14. package/dist/cjs/index.cjs +2383 -3
  15. package/dist/cjs/linked-list.cjs +224 -2
  16. package/dist/cjs/matrix.cjs +24 -0
  17. package/dist/cjs/priority-queue.cjs +71 -0
  18. package/dist/cjs/queue.cjs +221 -1
  19. package/dist/cjs/stack.cjs +59 -0
  20. package/dist/cjs/trie.cjs +62 -0
  21. package/dist/cjs-legacy/binary-tree.cjs +1897 -19
  22. package/dist/cjs-legacy/graph.cjs +174 -0
  23. package/dist/cjs-legacy/hash.cjs +33 -0
  24. package/dist/cjs-legacy/heap.cjs +71 -0
  25. package/dist/cjs-legacy/index.cjs +2383 -3
  26. package/dist/cjs-legacy/linked-list.cjs +224 -2
  27. package/dist/cjs-legacy/matrix.cjs +24 -0
  28. package/dist/cjs-legacy/priority-queue.cjs +71 -0
  29. package/dist/cjs-legacy/queue.cjs +221 -1
  30. package/dist/cjs-legacy/stack.cjs +59 -0
  31. package/dist/cjs-legacy/trie.cjs +62 -0
  32. package/dist/esm/binary-tree.mjs +1897 -19
  33. package/dist/esm/graph.mjs +174 -0
  34. package/dist/esm/hash.mjs +33 -0
  35. package/dist/esm/heap.mjs +71 -0
  36. package/dist/esm/index.mjs +2383 -3
  37. package/dist/esm/linked-list.mjs +224 -2
  38. package/dist/esm/matrix.mjs +24 -0
  39. package/dist/esm/priority-queue.mjs +71 -0
  40. package/dist/esm/queue.mjs +221 -1
  41. package/dist/esm/stack.mjs +59 -0
  42. package/dist/esm/trie.mjs +62 -0
  43. package/dist/esm-legacy/binary-tree.mjs +1897 -19
  44. package/dist/esm-legacy/graph.mjs +174 -0
  45. package/dist/esm-legacy/hash.mjs +33 -0
  46. package/dist/esm-legacy/heap.mjs +71 -0
  47. package/dist/esm-legacy/index.mjs +2383 -3
  48. package/dist/esm-legacy/linked-list.mjs +224 -2
  49. package/dist/esm-legacy/matrix.mjs +24 -0
  50. package/dist/esm-legacy/priority-queue.mjs +71 -0
  51. package/dist/esm-legacy/queue.mjs +221 -1
  52. package/dist/esm-legacy/stack.mjs +59 -0
  53. package/dist/esm-legacy/trie.mjs +62 -0
  54. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  55. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  56. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  57. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  58. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  59. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  60. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  61. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  62. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  63. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  64. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  65. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  66. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  67. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  68. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  69. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  70. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  71. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  72. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  73. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  74. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  75. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  76. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  77. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  78. package/dist/umd/data-structure-typed.js +2383 -3
  79. package/dist/umd/data-structure-typed.min.js +3 -3
  80. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +108 -108
  81. package/docs-site-docusaurus/docs/api/classes/BST.md +101 -101
  82. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -13
  83. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +66 -66
  84. package/docs-site-docusaurus/docs/api/classes/Deque.md +235 -51
  85. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +21 -21
  86. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +231 -67
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  88. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  89. package/docs-site-docusaurus/docs/api/classes/HashMap.md +14 -14
  90. package/docs-site-docusaurus/docs/api/classes/Heap.md +117 -34
  91. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +83 -13
  92. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +124 -20
  93. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +140 -32
  94. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +30 -26
  95. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +159 -51
  96. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +20 -20
  97. package/docs-site-docusaurus/docs/api/classes/Matrix.md +23 -23
  98. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -34
  99. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +117 -34
  100. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -34
  101. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +117 -34
  102. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +117 -34
  103. package/docs-site-docusaurus/docs/api/classes/Queue.md +142 -34
  104. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +117 -117
  105. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +8 -8
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +158 -50
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +21 -21
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +108 -26
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +33 -33
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +75 -39
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +301 -39
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +110 -28
  113. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +20 -20
  114. package/jest.integration.config.js +1 -2
  115. package/package.json +51 -50
  116. package/src/common/error.ts +15 -32
  117. package/src/common/index.ts +0 -3
  118. package/src/data-structures/base/iterable-element-base.ts +32 -3
  119. package/src/data-structures/base/linear-base.ts +13 -36
  120. package/src/data-structures/binary-tree/avl-tree.ts +31 -493
  121. package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -530
  122. package/src/data-structures/binary-tree/binary-tree.ts +326 -1236
  123. package/src/data-structures/binary-tree/bst.ts +158 -1010
  124. package/src/data-structures/binary-tree/red-black-tree.ts +451 -1233
  125. package/src/data-structures/binary-tree/segment-tree.ts +73 -333
  126. package/src/data-structures/binary-tree/tree-map.ts +462 -4749
  127. package/src/data-structures/binary-tree/tree-multi-map.ts +310 -4530
  128. package/src/data-structures/binary-tree/tree-multi-set.ts +300 -3652
  129. package/src/data-structures/binary-tree/tree-set.ts +437 -4443
  130. package/src/data-structures/graph/abstract-graph.ts +98 -167
  131. package/src/data-structures/graph/directed-graph.ts +137 -532
  132. package/src/data-structures/graph/map-graph.ts +0 -3
  133. package/src/data-structures/graph/undirected-graph.ts +132 -484
  134. package/src/data-structures/hash/hash-map.ts +154 -549
  135. package/src/data-structures/heap/heap.ts +200 -753
  136. package/src/data-structures/linked-list/doubly-linked-list.ts +153 -809
  137. package/src/data-structures/linked-list/singly-linked-list.ts +122 -749
  138. package/src/data-structures/linked-list/skip-linked-list.ts +211 -864
  139. package/src/data-structures/matrix/matrix.ts +179 -494
  140. package/src/data-structures/matrix/navigator.ts +0 -1
  141. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
  142. package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
  143. package/src/data-structures/priority-queue/priority-queue.ts +1 -2
  144. package/src/data-structures/queue/deque.ts +241 -807
  145. package/src/data-structures/queue/queue.ts +102 -589
  146. package/src/data-structures/stack/stack.ts +76 -475
  147. package/src/data-structures/trie/trie.ts +98 -592
  148. package/src/types/common.ts +0 -10
  149. package/src/types/data-structures/binary-tree/bst.ts +0 -7
  150. package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
  151. package/src/types/data-structures/graph/abstract-graph.ts +0 -2
  152. package/src/types/data-structures/hash/hash-map.ts +0 -3
  153. package/src/types/data-structures/hash/index.ts +0 -1
  154. package/src/types/data-structures/matrix/navigator.ts +0 -2
  155. package/src/types/utils/utils.ts +0 -7
  156. package/src/types/utils/validate-type.ts +0 -7
  157. package/src/utils/number.ts +0 -2
  158. package/src/utils/utils.ts +0 -5
@@ -36,11 +36,16 @@ jobs:
36
36
  with:
37
37
  node-version: ${{ matrix.node-version }}
38
38
 
39
+ - name: Install pnpm
40
+ uses: pnpm/action-setup@v4
41
+ with:
42
+ version: 10
43
+
39
44
  - name: Install dependencies
40
- run: npm install
45
+ run: pnpm install
41
46
 
42
47
  - name: Combined ci commands together
43
- run: npm run ci
48
+ run: pnpm inspect && pnpm test:coverage
44
49
 
45
50
  - name: Upload coverage reports to Codecov
46
51
  uses: codecov/codecov-action@v5
@@ -12,7 +12,10 @@ jobs:
12
12
  - uses: actions/setup-node@v3
13
13
  with:
14
14
  node-version: 19
15
- - run: npm ci
15
+ - uses: pnpm/action-setup@v4
16
+ with:
17
+ version: 10
18
+ - run: pnpm install --frozen-lockfile
16
19
 
17
20
  publish-gpr:
18
21
  needs: build
@@ -26,7 +29,11 @@ jobs:
26
29
  with:
27
30
  node-version: 19
28
31
  registry-url: https://npm.pkg.github.com/
29
- - run: npm publish
32
+ - uses: pnpm/action-setup@v4
33
+ with:
34
+ version: 10
35
+ - run: pnpm install --frozen-lockfile
36
+ - run: pnpm publish --no-git-checks
30
37
  env:
31
38
  NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
32
39
  # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ echo "🔍 Pre-commit: check + lint + integration tests..."
3
+ npm run check && npm run lint && npx jest --config jest.integration.config.js
package/CHANGELOG.md CHANGED
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
8
8
  - [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
9
9
  - [`auto-changelog`](https://github.com/CookPete/auto-changelog)
10
10
 
11
- ## [v2.5.3](https://github.com/zrwusa/data-structure-typed/compare/v2.5.3...main) (upcoming)
11
+ ## [v2.6.0](https://github.com/zrwusa/data-structure-typed/compare/v2.5.3...main) (upcoming)
12
12
 
13
13
  ## [v2.5.3](https://github.com/zrwusa/data-structure-typed/compare/v2.5.1...v2.5.3) (31 March 2026)
14
14
 
package/MIGRATION.md CHANGED
@@ -124,10 +124,58 @@ heap.deleteBy(e => e.id === 42);
124
124
  heap.deleteWhere(e => e.id === 42);
125
125
  ```
126
126
 
127
+ #### `DoublyLinkedList.getBackward()` → use `findLast()`
128
+
129
+ ```typescript
130
+ // Deprecated
131
+ list.getBackward(node => node.value > 5);
132
+
133
+ // Preferred (aligns with ES2023 Array.findLast)
134
+ list.findLast(node => node.value > 5);
135
+ ```
136
+
127
137
  ---
128
138
 
129
139
  ### New Features
130
140
 
141
+ #### Array-Compatible APIs (v2.5.4+)
142
+
143
+ All `IterableElementBase` containers (Queue, Deque, Stack, LinkedList, Heap, Trie) now support:
144
+
145
+ ```typescript
146
+ structure.includes(element); // alias for has()
147
+ [...structure.entries()]; // [[0, val0], [1, val1], ...]
148
+ [...structure.keys()]; // [0, 1, 2, ...]
149
+ structure.toReversed(); // new instance, reversed (linear containers)
150
+ ```
151
+
152
+ #### Back-to-Front Search (v2.5.4+)
153
+
154
+ ```typescript
155
+ // Deque + DoublyLinkedList
156
+ deque.findLast(v => v > 10); // last matching value
157
+ deque.findLastIndex(v => v > 10); // last matching index, or -1
158
+ ```
159
+
160
+ #### TreeSet ES2025 Set Operations (v2.5.4+)
161
+
162
+ ```typescript
163
+ const a = new TreeSet([1, 2, 3, 4, 5]);
164
+ const b = new TreeSet([3, 4, 5, 6, 7]);
165
+
166
+ a.union(b); // TreeSet [1,2,3,4,5,6,7]
167
+ a.intersection(b); // TreeSet [3,4,5]
168
+ a.difference(b); // TreeSet [1,2]
169
+ a.symmetricDifference(b); // TreeSet [1,2,6,7]
170
+ a.isSubsetOf(b); // false
171
+ a.isSupersetOf(b); // false
172
+ a.isDisjointFrom(b); // false
173
+
174
+ // Works with any Iterable
175
+ a.union([10, 11]);
176
+ a.intersection(new Set([2, 4]));
177
+ ```
178
+
131
179
  #### `deleteWhere()` — conditional deletion
132
180
 
133
181
  Available on: `TreeMap`, `TreeSet`, `TreeMultiMap`, `TreeMultiSet`, `DoublyLinkedList`, `Queue`, `Heap`
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  English | [简体中文](./README_CN.md)
4
4
 
5
- A production-ready TypeScript data structures library featuring **Heap, Priority Queue, Deque, Trie, Graph, Red-Black Tree, TreeMap, TreeSet, SkipList, Segment Tree**, and more — with an API that feels as intuitive as JavaScript's native `Array`. Zero dependencies. Type-safe. Supports rank queries (`getRank`), positional access (`getByRank`), and range queries (`rangeByRank`).
5
+ A production-ready TypeScript data structures library featuring **Heap, Linked List, Deque, Trie, Graph, Red-Black Tree, TreeMap, TreeSet, SkipList, Segment Tree**, and more — with APIs that align with JavaScript's native **Array, Map, and Set**. Zero dependencies. Type-safe. ES2025 Set operations. O(log n) rank & range queries.
6
6
 
7
- > **Looking for a TreeMap or TreeSet in JavaScript?** Need a priority queue, an ordered set, or efficient rank/range queries? Tired of repeatedly sorting arrays after every insert? This library provides all of that with a unified, Array-like API.
7
+ > **Looking for a TreeMap, TreeSet, or PriorityQueue in TypeScript/JavaScript?** Familiar API, set operations, rank queries, sorted access no more repeated `Array.sort()`.
8
8
 
9
9
  ![npm](https://img.shields.io/npm/dm/data-structure-typed)
10
10
  ![GitHub contributors](https://img.shields.io/github/contributors/zrwusa/data-structure-typed)
@@ -362,6 +362,24 @@ taskQueue.add({ priority: 9, task: 'Alert' }); // Instant priority handling
362
362
  const nextTask = taskQueue.pop(); // { priority: 9, task: 'Alert' }
363
363
  ```
364
364
 
365
+ ### Set Operations (ES2025)
366
+
367
+ ```typescript
368
+ import { TreeSet } from 'data-structure-typed';
369
+
370
+ const a = new TreeSet([1, 2, 3, 4, 5]);
371
+ const b = new TreeSet([3, 4, 5, 6, 7]);
372
+
373
+ [...a.union(b)]; // [1,2,3,4,5,6,7]
374
+ [...a.intersection(b)]; // [3,4,5]
375
+ [...a.difference(b)]; // [1,2]
376
+ [...a.symmetricDifference(b)]; // [1,2,6,7]
377
+ a.isSubsetOf(b); // false
378
+
379
+ // Works with any Iterable — native Set, arrays, generators
380
+ a.intersection(new Set([2, 4, 6])); // TreeSet [2, 4]
381
+ ```
382
+
365
383
  ### Fast Queue (FIFO)
366
384
 
367
385
  ```typescript
package/README_CN.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [English](./README.md) | 简体中文
4
4
 
5
- 一个生产就绪的 TypeScript 数据结构库,提供 **Heap、Priority Queue、Deque、Trie、Graph、Red-Black Tree、TreeMap、TreeSet、SkipList、Segment Tree** 等数据结构,其 API 就像 JavaScript 原生 `Array` 一样直观。零依赖。类型安全。支持排名查询(`getRank`)、位置访问(`getByRank`)和范围查询(`rangeByRank`)。
5
+ 一个生产就绪的 TypeScript 数据结构库,包含 **Heap、Linked List、Deque、Trie、Graph、Red-Black Tree、TreeMap、TreeSet、SkipList、Segment Tree** API 对齐 JavaScript 原生 **Array、Map 和 Set**。零依赖。类型安全。ES2025 Set 操作。O(log n) 排名和范围查询。
6
6
 
7
- > **在 JavaScript 中寻找 TreeMap 或 TreeSet?** 需要优先级队列、有序集合或高效的排名/范围查询?厌倦了每次插入后反复排序数组?这个库提供了所有这些功能,并配有统一的、类似 Array API。
7
+ > **在 TypeScript/JavaScript 中寻找 TreeMap、TreeSetPriorityQueue?** 熟悉的 API、集合操作、排名查询、有序访问 告别重复 `Array.sort()`。
8
8
 
9
9
  ![npm](https://img.shields.io/npm/dm/data-structure-typed)
10
10
  ![GitHub contributors](https://img.shields.io/github/contributors/zrwusa/data-structure-typed)
@@ -362,6 +362,24 @@ taskQueue.add({ priority: 9, task: 'Alert' }); // 即时优先级处理
362
362
  const nextTask = taskQueue.pop(); // { priority: 9, task: 'Alert' }
363
363
  ```
364
364
 
365
+ ### 集合操作 (ES2025)
366
+
367
+ ```typescript
368
+ import { TreeSet } from 'data-structure-typed';
369
+
370
+ const a = new TreeSet([1, 2, 3, 4, 5]);
371
+ const b = new TreeSet([3, 4, 5, 6, 7]);
372
+
373
+ [...a.union(b)]; // [1,2,3,4,5,6,7]
374
+ [...a.intersection(b)]; // [3,4,5]
375
+ [...a.difference(b)]; // [1,2]
376
+ [...a.symmetricDifference(b)]; // [1,2,6,7]
377
+ a.isSubsetOf(b); // false
378
+
379
+ // 支持任意 Iterable — 原生 Set、数组、生成器
380
+ a.intersection(new Set([2, 4, 6])); // TreeSet [2, 4]
381
+ ```
382
+
365
383
  ### 快速队列 (FIFO)
366
384
 
367
385
  ```typescript
package/SPECIFICATION.md CHANGED
@@ -116,6 +116,16 @@ structure.peek(): T | undefined // View front element (Queue/Deque/S
116
116
  structure.first: T | undefined // View first element (getter)
117
117
  structure.last: T | undefined // View last element (getter)
118
118
 
119
+ // Search (back-to-front)
120
+ structure.findLast(pred: Function): T | undefined // Deque, DoublyLinkedList
121
+ structure.findLastIndex(pred: Function): number // Deque, DoublyLinkedList
122
+
123
+ // Array-compatible (migration helpers)
124
+ structure.includes(element: T): boolean // Alias for has()
125
+ structure.entries(): IterableIterator<[number, T]> // [index, value] pairs
126
+ structure.keys(): IterableIterator<number> // Index iterator
127
+ structure.toReversed(): this // Non-mutating reverse (new instance)
128
+
119
129
  // Size and queries
120
130
  structure.size: number // Element count (Stack, Trie, etc.)
121
131
  structure.length: number // Element count (Queue, Deque, LinkedList)
@@ -167,6 +177,20 @@ heap.size: number
167
177
  heap.isEmpty(): boolean
168
178
  ```
169
179
 
180
+ ### TreeSet — ES2025 Set Operations
181
+
182
+ ```typescript
183
+ treeSet.union(other: Iterable<K>): TreeSet<K>
184
+ treeSet.intersection(other: Iterable<K>): TreeSet<K>
185
+ treeSet.difference(other: Iterable<K>): TreeSet<K>
186
+ treeSet.symmetricDifference(other: Iterable<K>): TreeSet<K>
187
+ treeSet.isSubsetOf(other: Iterable<K>): boolean
188
+ treeSet.isSupersetOf(other: Iterable<K>): boolean
189
+ treeSet.isDisjointFrom(other: Iterable<K>): boolean
190
+ ```
191
+
192
+ All accept any `Iterable<K>` (TreeSet, native Set, Array, generators).
193
+
170
194
  ### Array Methods (Available on All Structures)
171
195
 
172
196
  **All structures support ES6+ array methods via iteration:**
@@ -116,6 +116,16 @@ structure.peek(): T | undefined // 查看队头元素(Queue/Deque/
116
116
  structure.first: T | undefined // 查看第一个元素(getter)
117
117
  structure.last: T | undefined // 查看最后一个元素(getter)
118
118
 
119
+ // 反向查找
120
+ structure.findLast(pred: Function): T | undefined // Deque、DoublyLinkedList
121
+ structure.findLastIndex(pred: Function): number // Deque、DoublyLinkedList
122
+
123
+ // Array 兼容(方便迁移)
124
+ structure.includes(element: T): boolean // has() 的别名
125
+ structure.entries(): IterableIterator<[number, T]> // [index, value] 对
126
+ structure.keys(): IterableIterator<number> // 索引迭代器
127
+ structure.toReversed(): this // 非破坏性反转(返回新实例)
128
+
119
129
  // 大小和查询
120
130
  structure.size: number // 元素数量(Stack、Trie 等)
121
131
  structure.length: number // 元素数量(Queue、Deque、LinkedList)
@@ -167,6 +177,20 @@ heap.size: number
167
177
  heap.isEmpty(): boolean
168
178
  ```
169
179
 
180
+ ### TreeSet — ES2025 集合操作
181
+
182
+ ```typescript
183
+ treeSet.union(other: Iterable<K>): TreeSet<K> // 并集
184
+ treeSet.intersection(other: Iterable<K>): TreeSet<K> // 交集
185
+ treeSet.difference(other: Iterable<K>): TreeSet<K> // 差集
186
+ treeSet.symmetricDifference(other: Iterable<K>): TreeSet<K>// 对称差集
187
+ treeSet.isSubsetOf(other: Iterable<K>): boolean // 子集判断
188
+ treeSet.isSupersetOf(other: Iterable<K>): boolean // 超集判断
189
+ treeSet.isDisjointFrom(other: Iterable<K>): boolean // 不相交判断
190
+ ```
191
+
192
+ 接受任何 `Iterable<K>`(TreeSet、原生 Set、数组、生成器)。
193
+
170
194
  ### 数组方法(所有结构上可用)
171
195
 
172
196
  **所有结构通过迭代支持 ES6+ 数组方法:**