@blackglory/structures 0.15.0 → 0.15.2

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 (79) hide show
  1. package/README.md +13 -0
  2. package/lib/bit-set/bit-set.d.ts +1 -1
  3. package/lib/bit-set/bit-set.js +6 -6
  4. package/lib/bit-set/bit-set.js.map +1 -1
  5. package/lib/bit-set/dynamic-typed-bit-set.d.ts +1 -1
  6. package/lib/bit-set/dynamic-typed-bit-set.js +5 -5
  7. package/lib/bit-set/dynamic-typed-bit-set.js.map +1 -1
  8. package/lib/bit-set/resizable-typed-bit-set.d.ts +1 -1
  9. package/lib/bit-set/resizable-typed-bit-set.js +5 -5
  10. package/lib/bit-set/resizable-typed-bit-set.js.map +1 -1
  11. package/lib/bit-set/typed-bit-set.d.ts +1 -1
  12. package/lib/bit-set/typed-bit-set.js +5 -5
  13. package/lib/bit-set/typed-bit-set.js.map +1 -1
  14. package/lib/dynamic-typed-array.d.ts +1 -1
  15. package/lib/dynamic-typed-array.js +14 -14
  16. package/lib/dynamic-typed-array.js.map +1 -1
  17. package/lib/index.d.ts +1 -0
  18. package/lib/index.js +1 -0
  19. package/lib/index.js.map +1 -1
  20. package/lib/resizable-typed-array.d.ts +1 -1
  21. package/lib/resizable-typed-array.js +14 -14
  22. package/lib/resizable-typed-array.js.map +1 -1
  23. package/lib/sparse-map/typed-clean-sparse-map-lite.d.ts +1 -1
  24. package/lib/sparse-map/typed-clean-sparse-map-lite.js +8 -8
  25. package/lib/sparse-map/typed-clean-sparse-map-lite.js.map +1 -1
  26. package/lib/sparse-map/typed-clean-sparse-map.d.ts +1 -1
  27. package/lib/sparse-map/typed-clean-sparse-map.js +9 -9
  28. package/lib/sparse-map/typed-clean-sparse-map.js.map +1 -1
  29. package/lib/sparse-map/typed-sparse-map-lite.d.ts +1 -1
  30. package/lib/sparse-map/typed-sparse-map-lite.js +13 -13
  31. package/lib/sparse-map/typed-sparse-map-lite.js.map +1 -1
  32. package/lib/sparse-map/typed-sparse-map.d.ts +1 -1
  33. package/lib/sparse-map/typed-sparse-map.js +14 -14
  34. package/lib/sparse-map/typed-sparse-map.js.map +1 -1
  35. package/lib/sparse-set/dynamic-typed-clean-sparse-set.js +1 -1
  36. package/lib/sparse-set/dynamic-typed-clean-sparse-set.js.map +1 -1
  37. package/lib/sparse-set/dynamic-typed-sparse-set.js +1 -1
  38. package/lib/sparse-set/dynamic-typed-sparse-set.js.map +1 -1
  39. package/lib/sparse-set/resizable-typed-clean-sparse-set.js +1 -1
  40. package/lib/sparse-set/resizable-typed-clean-sparse-set.js.map +1 -1
  41. package/lib/sparse-set/resizable-typed-sparse-set.js +1 -1
  42. package/lib/sparse-set/resizable-typed-sparse-set.js.map +1 -1
  43. package/lib/sparse-set/typed-clean-sparse-set-lite.d.ts +1 -1
  44. package/lib/sparse-set/typed-clean-sparse-set-lite.js +6 -6
  45. package/lib/sparse-set/typed-clean-sparse-set-lite.js.map +1 -1
  46. package/lib/sparse-set/typed-clean-sparse-set.d.ts +1 -1
  47. package/lib/sparse-set/typed-clean-sparse-set.js +7 -7
  48. package/lib/sparse-set/typed-clean-sparse-set.js.map +1 -1
  49. package/lib/sparse-set/typed-sparse-set-lite.d.ts +1 -1
  50. package/lib/sparse-set/typed-sparse-set-lite.js +8 -8
  51. package/lib/sparse-set/typed-sparse-set-lite.js.map +1 -1
  52. package/lib/sparse-set/typed-sparse-set.d.ts +1 -1
  53. package/lib/sparse-set/typed-sparse-set.js +9 -9
  54. package/lib/sparse-set/typed-sparse-set.js.map +1 -1
  55. package/lib/{utils/get-max-value-of-unsigned-typed-array.js → typed-array.js} +1 -1
  56. package/lib/typed-array.js.map +1 -0
  57. package/package.json +1 -1
  58. package/src/bit-set/bit-set.ts +6 -6
  59. package/src/bit-set/dynamic-typed-bit-set.ts +5 -5
  60. package/src/bit-set/resizable-typed-bit-set.ts +5 -5
  61. package/src/bit-set/typed-bit-set.ts +5 -5
  62. package/src/dynamic-typed-array.ts +14 -14
  63. package/src/index.ts +1 -0
  64. package/src/resizable-typed-array.ts +14 -14
  65. package/src/sparse-map/typed-clean-sparse-map-lite.ts +8 -8
  66. package/src/sparse-map/typed-clean-sparse-map.ts +9 -9
  67. package/src/sparse-map/typed-sparse-map-lite.ts +13 -13
  68. package/src/sparse-map/typed-sparse-map.ts +14 -14
  69. package/src/sparse-set/dynamic-typed-clean-sparse-set.ts +1 -1
  70. package/src/sparse-set/dynamic-typed-sparse-set.ts +1 -1
  71. package/src/sparse-set/resizable-typed-clean-sparse-set.ts +1 -1
  72. package/src/sparse-set/resizable-typed-sparse-set.ts +1 -1
  73. package/src/sparse-set/typed-clean-sparse-set-lite.ts +6 -6
  74. package/src/sparse-set/typed-clean-sparse-set.ts +7 -7
  75. package/src/sparse-set/typed-sparse-set-lite.ts +8 -8
  76. package/src/sparse-set/typed-sparse-set.ts +9 -9
  77. package/lib/utils/get-max-value-of-unsigned-typed-array.js.map +0 -1
  78. /package/lib/{utils/get-max-value-of-unsigned-typed-array.d.ts → typed-array.d.ts} +0 -0
  79. /package/src/{utils/get-max-value-of-unsigned-typed-array.ts → typed-array.ts} +0 -0
@@ -8,7 +8,7 @@ export class TypedCleanSparseMapLite<
8
8
  private denseKeys: TypedArrayOfConstructor<K>
9
9
  private denseValues: TypedArrayOfConstructor<V>
10
10
  private sparse: Array<number | undefined> = []
11
- #length = 0
11
+ private _length = 0
12
12
 
13
13
  readonly internalKeyArray: TypedArrayOfConstructor<K, ArrayBuffer>
14
14
  readonly internalValueArray: TypedArrayOfConstructor<V, ArrayBuffer>
@@ -18,7 +18,7 @@ export class TypedCleanSparseMapLite<
18
18
  }
19
19
 
20
20
  get size(): number {
21
- return this.#length
21
+ return this._length
22
22
  }
23
23
 
24
24
  constructor(
@@ -40,7 +40,7 @@ export class TypedCleanSparseMapLite<
40
40
  }
41
41
 
42
42
  * entries(): IterableIterator<[key: number, value: number]> {
43
- for (let i = 0; i < this.#length; i++) {
43
+ for (let i = 0; i < this._length; i++) {
44
44
  yield [
45
45
  this.denseKeys[i]
46
46
  , this.denseValues[i]
@@ -49,13 +49,13 @@ export class TypedCleanSparseMapLite<
49
49
  }
50
50
 
51
51
  * keys(): IterableIterator<number> {
52
- for (let i = 0; i < this.#length; i++) {
52
+ for (let i = 0; i < this._length; i++) {
53
53
  yield this.denseKeys[i]
54
54
  }
55
55
  }
56
56
 
57
57
  * values(): IterableIterator<number> {
58
- for (let i = 0; i < this.#length; i++) {
58
+ for (let i = 0; i < this._length; i++) {
59
59
  yield this.denseValues[i]
60
60
  }
61
61
  }
@@ -82,7 +82,7 @@ export class TypedCleanSparseMapLite<
82
82
  if (index !== undefined) {
83
83
  this.denseValues[index] = value
84
84
  } else {
85
- const index = this.#length++
85
+ const index = this._length++
86
86
  this.denseKeys[index] = key
87
87
  this.denseValues[index] = value
88
88
  this.sparse[key] = index
@@ -94,7 +94,7 @@ export class TypedCleanSparseMapLite<
94
94
  if (index !== undefined) {
95
95
  this.sparse[key] = undefined
96
96
 
97
- const lastIndex = --this.#length
97
+ const lastIndex = --this._length
98
98
  const lastKey = this.denseKeys[lastIndex]
99
99
  const lastValue = this.denseValues[lastIndex]
100
100
  if (key !== lastKey) {
@@ -110,7 +110,7 @@ export class TypedCleanSparseMapLite<
110
110
  }
111
111
 
112
112
  clear(): void {
113
- this.#length = 0
113
+ this._length = 0
114
114
  this.sparse.length = 0
115
115
  }
116
116
  }
@@ -1,6 +1,6 @@
1
1
  import { assert } from '@blackglory/errors'
2
2
  import { go } from '@blackglory/go'
3
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
3
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
4
4
  import { TypedArrayConstructor, UnsignedTypedArrayConstructor, TypedArrayOfConstructor, UnsignedTypedArray } from 'justypes'
5
5
 
6
6
  export class TypedCleanSparseMap<
@@ -11,7 +11,7 @@ export class TypedCleanSparseMap<
11
11
  private denseValues: TypedArrayOfConstructor<V>
12
12
  private sparse: UnsignedTypedArray
13
13
  private readonly NULL: number
14
- #length = 0
14
+ private _length = 0
15
15
 
16
16
  readonly internalKeyArray: TypedArrayOfConstructor<K, ArrayBuffer>
17
17
  readonly internalValueArray: TypedArrayOfConstructor<V, ArrayBuffer>
@@ -21,7 +21,7 @@ export class TypedCleanSparseMap<
21
21
  }
22
22
 
23
23
  get size(): number {
24
- return this.#length
24
+ return this._length
25
25
  }
26
26
 
27
27
  constructor(
@@ -73,7 +73,7 @@ export class TypedCleanSparseMap<
73
73
  }
74
74
 
75
75
  * entries(): IterableIterator<[key: number, value: number]> {
76
- for (let i = 0; i < this.#length; i++) {
76
+ for (let i = 0; i < this._length; i++) {
77
77
  yield [
78
78
  this.denseKeys[i]
79
79
  , this.denseValues[i]
@@ -82,13 +82,13 @@ export class TypedCleanSparseMap<
82
82
  }
83
83
 
84
84
  * keys(): IterableIterator<number> {
85
- for (let i = 0; i < this.#length; i++) {
85
+ for (let i = 0; i < this._length; i++) {
86
86
  yield this.denseKeys[i]
87
87
  }
88
88
  }
89
89
 
90
90
  * values(): IterableIterator<number> {
91
- for (let i = 0; i < this.#length; i++) {
91
+ for (let i = 0; i < this._length; i++) {
92
92
  yield this.denseValues[i]
93
93
  }
94
94
  }
@@ -115,7 +115,7 @@ export class TypedCleanSparseMap<
115
115
  if (index !== this.NULL) {
116
116
  this.denseValues[index] = value
117
117
  } else {
118
- const index = this.#length++
118
+ const index = this._length++
119
119
  this.denseKeys[index] = key
120
120
  this.denseValues[index] = value
121
121
  this.sparse[key] = index
@@ -127,7 +127,7 @@ export class TypedCleanSparseMap<
127
127
  if (index !== this.NULL) {
128
128
  this.sparse[key] = this.NULL
129
129
 
130
- const lastIndex = --this.#length
130
+ const lastIndex = --this._length
131
131
  const lastKey = this.denseKeys[lastIndex]
132
132
  const lastValue = this.denseValues[lastIndex]
133
133
  if (key !== lastKey) {
@@ -143,7 +143,7 @@ export class TypedCleanSparseMap<
143
143
  }
144
144
 
145
145
  clear(): void {
146
- this.#length = 0
146
+ this._length = 0
147
147
  this.sparse.fill(this.NULL)
148
148
  }
149
149
  }
@@ -8,7 +8,7 @@ export class TypedSparseMapLite<
8
8
  private denseKeys: TypedArrayOfConstructor<K>
9
9
  private denseValues: TypedArrayOfConstructor<V>
10
10
  private sparse: Array<number | undefined> = []
11
- #length = 0
11
+ private _length = 0
12
12
 
13
13
  readonly internalKeyArray: TypedArrayOfConstructor<K, ArrayBuffer>
14
14
  readonly internalValueArray: TypedArrayOfConstructor<V, ArrayBuffer>
@@ -18,7 +18,7 @@ export class TypedSparseMapLite<
18
18
  }
19
19
 
20
20
  get size(): number {
21
- return this.#length
21
+ return this._length
22
22
  }
23
23
 
24
24
  constructor(
@@ -40,7 +40,7 @@ export class TypedSparseMapLite<
40
40
  }
41
41
 
42
42
  * entries(): IterableIterator<[key: number, value: number]> {
43
- for (let i = 0; i < this.#length; i++) {
43
+ for (let i = 0; i < this._length; i++) {
44
44
  yield [
45
45
  this.denseKeys[i]
46
46
  , this.denseValues[i]
@@ -49,13 +49,13 @@ export class TypedSparseMapLite<
49
49
  }
50
50
 
51
51
  * keys(): IterableIterator<number> {
52
- for (let i = 0; i < this.#length; i++) {
52
+ for (let i = 0; i < this._length; i++) {
53
53
  yield this.denseKeys[i]
54
54
  }
55
55
  }
56
56
 
57
57
  * values(): IterableIterator<number> {
58
- for (let i = 0; i < this.#length; i++) {
58
+ for (let i = 0; i < this._length; i++) {
59
59
  yield this.denseValues[i]
60
60
  }
61
61
  }
@@ -64,7 +64,7 @@ export class TypedSparseMapLite<
64
64
  const index = this.sparse[key]
65
65
  if (
66
66
  index !== undefined &&
67
- index < this.#length &&
67
+ index < this._length &&
68
68
  index < this.denseKeys.length && // 用于改善JIT优化.
69
69
  this.denseKeys[index] === key
70
70
  ) {
@@ -75,7 +75,7 @@ export class TypedSparseMapLite<
75
75
  has(key: number): boolean {
76
76
  const index = this.sparse[key]
77
77
  return index !== undefined
78
- && index < this.#length
78
+ && index < this._length
79
79
  && index < this.denseKeys.length // 用于改善JIT优化.
80
80
  && this.denseKeys[index] === key
81
81
  }
@@ -84,7 +84,7 @@ export class TypedSparseMapLite<
84
84
  const index = this.sparse[key]
85
85
  if (
86
86
  index !== undefined &&
87
- index < this.#length &&
87
+ index < this._length &&
88
88
  index < this.denseKeys.length && // 用于改善JIT优化.
89
89
  this.denseKeys[index] === key
90
90
  ) {
@@ -98,13 +98,13 @@ export class TypedSparseMapLite<
98
98
  const index = this.sparse[key]
99
99
  if (
100
100
  index !== undefined &&
101
- index < this.#length &&
101
+ index < this._length &&
102
102
  index < this.denseKeys.length && // 用于改善JIT优化.
103
103
  this.denseKeys[index] === key
104
104
  ) {
105
105
  this.denseValues[index] = value
106
106
  } else {
107
- const index = this.#length++
107
+ const index = this._length++
108
108
  this.denseKeys[index] = key
109
109
  this.denseValues[index] = value
110
110
  this.sparse[key] = index
@@ -115,11 +115,11 @@ export class TypedSparseMapLite<
115
115
  const index = this.sparse[key]
116
116
  if (
117
117
  index !== undefined &&
118
- index < this.#length &&
118
+ index < this._length &&
119
119
  index < this.denseKeys.length && // 用于改善JIT优化.
120
120
  this.denseKeys[index] === key
121
121
  ) {
122
- const lastIndex = --this.#length
122
+ const lastIndex = --this._length
123
123
  const lastKey = this.denseKeys[lastIndex]
124
124
  const lastValue = this.denseValues[lastIndex]
125
125
  if (key !== lastKey) {
@@ -135,7 +135,7 @@ export class TypedSparseMapLite<
135
135
  }
136
136
 
137
137
  clear(): void {
138
- this.#length = 0
138
+ this._length = 0
139
139
  // 无需清空dense和sparse数组.
140
140
  }
141
141
  }
@@ -1,6 +1,6 @@
1
1
  import { assert } from '@blackglory/errors'
2
2
  import { go } from '@blackglory/go'
3
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
3
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
4
4
  import { TypedArrayConstructor, UnsignedTypedArrayConstructor, TypedArrayOfConstructor, UnsignedTypedArray } from 'justypes'
5
5
 
6
6
  export class TypedSparseMap<
@@ -10,7 +10,7 @@ export class TypedSparseMap<
10
10
  private denseKeys: TypedArrayOfConstructor<K>
11
11
  private denseValues: TypedArrayOfConstructor<V>
12
12
  private sparse: UnsignedTypedArray
13
- #length = 0
13
+ private _length = 0
14
14
 
15
15
  readonly internalKeyArray: TypedArrayOfConstructor<K, ArrayBuffer>
16
16
  readonly internalValueArray: TypedArrayOfConstructor<V, ArrayBuffer>
@@ -20,7 +20,7 @@ export class TypedSparseMap<
20
20
  }
21
21
 
22
22
  get size(): number {
23
- return this.#length
23
+ return this._length
24
24
  }
25
25
 
26
26
  constructor(
@@ -68,7 +68,7 @@ export class TypedSparseMap<
68
68
  }
69
69
 
70
70
  * entries(): IterableIterator<[key: number, value: number]> {
71
- for (let i = 0; i < this.#length; i++) {
71
+ for (let i = 0; i < this._length; i++) {
72
72
  yield [
73
73
  this.denseKeys[i]
74
74
  , this.denseValues[i]
@@ -77,13 +77,13 @@ export class TypedSparseMap<
77
77
  }
78
78
 
79
79
  * keys(): IterableIterator<number> {
80
- for (let i = 0; i < this.#length; i++) {
80
+ for (let i = 0; i < this._length; i++) {
81
81
  yield this.denseKeys[i]
82
82
  }
83
83
  }
84
84
 
85
85
  * values(): IterableIterator<number> {
86
- for (let i = 0; i < this.#length; i++) {
86
+ for (let i = 0; i < this._length; i++) {
87
87
  yield this.denseValues[i]
88
88
  }
89
89
  }
@@ -92,7 +92,7 @@ export class TypedSparseMap<
92
92
  const index = this.sparse[key]
93
93
  if (
94
94
  index !== undefined &&
95
- index < this.#length &&
95
+ index < this._length &&
96
96
  index < this.denseKeys.length && // 用于改善JIT优化.
97
97
  this.denseKeys[index] === key
98
98
  ) {
@@ -103,7 +103,7 @@ export class TypedSparseMap<
103
103
  has(key: number): boolean {
104
104
  const index = this.sparse[key]
105
105
  return index !== undefined
106
- && index < this.#length
106
+ && index < this._length
107
107
  && index < this.denseKeys.length // 用于改善JIT优化.
108
108
  && this.denseKeys[index] === key
109
109
  }
@@ -112,7 +112,7 @@ export class TypedSparseMap<
112
112
  const index = this.sparse[key]
113
113
  if (
114
114
  index !== undefined &&
115
- index < this.#length &&
115
+ index < this._length &&
116
116
  index < this.denseKeys.length && // 用于改善JIT优化.
117
117
  this.denseKeys[index] === key
118
118
  ) {
@@ -126,13 +126,13 @@ export class TypedSparseMap<
126
126
  const index = this.sparse[key]
127
127
  if (
128
128
  index !== undefined &&
129
- index < this.#length &&
129
+ index < this._length &&
130
130
  index < this.denseKeys.length && // 用于改善JIT优化.
131
131
  this.denseKeys[index] === key
132
132
  ) {
133
133
  this.denseValues[index] = value
134
134
  } else {
135
- const index = this.#length++
135
+ const index = this._length++
136
136
  this.denseKeys[index] = key
137
137
  this.denseValues[index] = value
138
138
  this.sparse[key] = index
@@ -143,11 +143,11 @@ export class TypedSparseMap<
143
143
  const index = this.sparse[key]
144
144
  if (
145
145
  index !== undefined &&
146
- index < this.#length &&
146
+ index < this._length &&
147
147
  index < this.denseKeys.length && // 用于改善JIT优化.
148
148
  this.denseKeys[index] === key
149
149
  ) {
150
- const lastIndex = --this.#length
150
+ const lastIndex = --this._length
151
151
  const lastKey = this.denseKeys[lastIndex]
152
152
  const lastValue = this.denseValues[lastIndex]
153
153
  if (key !== lastKey) {
@@ -163,7 +163,7 @@ export class TypedSparseMap<
163
163
  }
164
164
 
165
165
  clear(): void {
166
- this.#length = 0
166
+ this._length = 0
167
167
  // 无需清空dense和sparse数组.
168
168
  }
169
169
  }
@@ -1,7 +1,7 @@
1
1
  import { TypedArrayConstructor, UnsignedTypedArrayConstructor } from 'justypes'
2
2
  import { DynamicTypedArray } from '@src/dynamic-typed-array.js'
3
3
  import { assert } from '@blackglory/errors'
4
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
4
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
5
5
  import { go } from '@blackglory/go'
6
6
 
7
7
  export class DynamicTypedCleanSparseSet implements Iterable<number> {
@@ -2,7 +2,7 @@ import { UnsignedTypedArrayConstructor } from 'justypes'
2
2
  import { DynamicTypedArray } from '@src/dynamic-typed-array.js'
3
3
  import { assert } from '@blackglory/errors'
4
4
  import { go } from '@blackglory/go'
5
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
5
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
6
6
 
7
7
  export class DynamicTypedSparseSet implements Iterable<number> {
8
8
  private dense: DynamicTypedArray<UnsignedTypedArrayConstructor>
@@ -2,7 +2,7 @@ import { UnsignedTypedArrayConstructor } from 'justypes'
2
2
  import { ResizableTypedArray } from '@src/resizable-typed-array.js'
3
3
  import { assert } from '@blackglory/errors'
4
4
  import { go } from '@blackglory/go'
5
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
5
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
6
6
 
7
7
  export class ResizableTypedCleanSparseSet implements Iterable<number> {
8
8
  private dense: ResizableTypedArray<UnsignedTypedArrayConstructor>
@@ -1,6 +1,6 @@
1
1
  import { UnsignedTypedArrayConstructor } from 'justypes'
2
2
  import { ResizableTypedArray } from '@src/resizable-typed-array.js'
3
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
3
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
4
4
  import { go } from '@blackglory/go'
5
5
  import { assert } from '@blackglory/errors'
6
6
 
@@ -4,14 +4,14 @@ import { UnsignedTypedArray } from 'justypes'
4
4
  export class TypedCleanSparseSetLite implements Iterable<number> {
5
5
  private dense: UnsignedTypedArray
6
6
  private sparse: Array<number | undefined> = []
7
- #length = 0
7
+ private _length = 0
8
8
 
9
9
  get [Symbol.toStringTag](): string {
10
10
  return this.constructor.name
11
11
  }
12
12
 
13
13
  get size(): number {
14
- return this.#length
14
+ return this._length
15
15
  }
16
16
 
17
17
  constructor(array: UnsignedTypedArray<ArrayBuffer>) {
@@ -25,7 +25,7 @@ export class TypedCleanSparseSetLite implements Iterable<number> {
25
25
  }
26
26
 
27
27
  * values(): IterableIterator<number> {
28
- for (let i = 0; i < this.#length; i++) {
28
+ for (let i = 0; i < this._length; i++) {
29
29
  yield this.dense[i]
30
30
  }
31
31
  }
@@ -36,7 +36,7 @@ export class TypedCleanSparseSetLite implements Iterable<number> {
36
36
 
37
37
  add(value: number): void {
38
38
  if (!this.has(value)) {
39
- const index = this.#length++
39
+ const index = this._length++
40
40
  this.dense[index] = value
41
41
  this.sparse[value] = index
42
42
  }
@@ -47,7 +47,7 @@ export class TypedCleanSparseSetLite implements Iterable<number> {
47
47
  if (index !== undefined) {
48
48
  this.sparse[value] = undefined
49
49
 
50
- const lastIndex = --this.#length
50
+ const lastIndex = --this._length
51
51
  const lastValue = this.dense[lastIndex]
52
52
  if (value !== lastValue) {
53
53
  this.dense[index] = lastValue
@@ -61,7 +61,7 @@ export class TypedCleanSparseSetLite implements Iterable<number> {
61
61
  }
62
62
 
63
63
  clear(): void {
64
- this.#length = 0
64
+ this._length = 0
65
65
  this.sparse.length = 0
66
66
  }
67
67
  }
@@ -1,20 +1,20 @@
1
1
  import { assert } from '@blackglory/errors'
2
2
  import { go } from '@blackglory/go'
3
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
3
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
4
4
  import { UnsignedTypedArray } from 'justypes'
5
5
 
6
6
  export class TypedCleanSparseSet implements Iterable<number> {
7
7
  private dense: UnsignedTypedArray
8
8
  private sparse: UnsignedTypedArray
9
9
  private readonly NULL: number
10
- #length = 0
10
+ private _length = 0
11
11
 
12
12
  get [Symbol.toStringTag](): string {
13
13
  return this.constructor.name
14
14
  }
15
15
 
16
16
  get size(): number {
17
- return this.#length
17
+ return this._length
18
18
  }
19
19
 
20
20
  constructor(array: UnsignedTypedArray<ArrayBuffer>) {
@@ -58,7 +58,7 @@ export class TypedCleanSparseSet implements Iterable<number> {
58
58
  }
59
59
 
60
60
  * values(): IterableIterator<number> {
61
- for (let i = 0; i < this.#length; i++) {
61
+ for (let i = 0; i < this._length; i++) {
62
62
  yield this.dense[i]
63
63
  }
64
64
  }
@@ -69,7 +69,7 @@ export class TypedCleanSparseSet implements Iterable<number> {
69
69
 
70
70
  add(value: number): void {
71
71
  if (!this.has(value)) {
72
- const index = this.#length++
72
+ const index = this._length++
73
73
  this.dense[index] = value
74
74
  this.sparse[value] = index
75
75
  }
@@ -80,7 +80,7 @@ export class TypedCleanSparseSet implements Iterable<number> {
80
80
  if (index !== this.NULL) {
81
81
  this.sparse[value] = this.NULL
82
82
 
83
- const lastIndex = --this.#length
83
+ const lastIndex = --this._length
84
84
  const lastValue = this.dense[lastIndex]
85
85
  if (value !== lastValue) {
86
86
  this.dense[index] = lastValue
@@ -94,7 +94,7 @@ export class TypedCleanSparseSet implements Iterable<number> {
94
94
  }
95
95
 
96
96
  clear(): void {
97
- this.#length = 0
97
+ this._length = 0
98
98
  this.sparse.fill(this.NULL)
99
99
  }
100
100
  }
@@ -4,14 +4,14 @@ import { UnsignedTypedArray } from 'justypes'
4
4
  export class TypedSparseSetLite implements Iterable<number> {
5
5
  private dense: UnsignedTypedArray
6
6
  private sparse: Array<number | undefined> = []
7
- #length = 0
7
+ private _length = 0
8
8
 
9
9
  get [Symbol.toStringTag](): string {
10
10
  return this.constructor.name
11
11
  }
12
12
 
13
13
  get size(): number {
14
- return this.#length
14
+ return this._length
15
15
  }
16
16
 
17
17
  constructor(array: UnsignedTypedArray<ArrayBuffer>) {
@@ -25,7 +25,7 @@ export class TypedSparseSetLite implements Iterable<number> {
25
25
  }
26
26
 
27
27
  * values(): IterableIterator<number> {
28
- for (let i = 0; i < this.#length; i++) {
28
+ for (let i = 0; i < this._length; i++) {
29
29
  yield this.dense[i]
30
30
  }
31
31
  }
@@ -33,14 +33,14 @@ export class TypedSparseSetLite implements Iterable<number> {
33
33
  has(value: number): boolean {
34
34
  const index = this.sparse[value]
35
35
  return index !== undefined
36
- && index < this.#length
36
+ && index < this._length
37
37
  && index < this.dense.length // 用于改善JIT优化.
38
38
  && this.dense[index] === value
39
39
  }
40
40
 
41
41
  add(value: number): void {
42
42
  if (!this.has(value)) {
43
- const index = this.#length++
43
+ const index = this._length++
44
44
  this.dense[index] = value
45
45
  this.sparse[value] = index
46
46
  }
@@ -50,11 +50,11 @@ export class TypedSparseSetLite implements Iterable<number> {
50
50
  const index = this.sparse[value]
51
51
  if (
52
52
  index !== undefined &&
53
- index < this.#length &&
53
+ index < this._length &&
54
54
  index < this.dense.length && // 用于改善JIT优化.
55
55
  this.dense[index] === value
56
56
  ) {
57
- const lastIndex = --this.#length
57
+ const lastIndex = --this._length
58
58
  const lastValue = this.dense[lastIndex]
59
59
  if (value !== lastValue) {
60
60
  this.dense[index] = lastValue
@@ -68,7 +68,7 @@ export class TypedSparseSetLite implements Iterable<number> {
68
68
  }
69
69
 
70
70
  clear(): void {
71
- this.#length = 0
71
+ this._length = 0
72
72
  // 无需清空dense和sparse数组.
73
73
  }
74
74
  }
@@ -1,19 +1,19 @@
1
1
  import { assert } from '@blackglory/errors'
2
2
  import { go } from '@blackglory/go'
3
- import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@utils/get-max-value-of-unsigned-typed-array.js'
3
+ import { getMaxValueOfUnsignedTypedArray, getMaxValueOfUnsignedTypedArrayConstructor } from '@src/typed-array.js'
4
4
  import { UnsignedTypedArray } from 'justypes'
5
5
 
6
6
  export class TypedSparseSet implements Iterable<number> {
7
7
  private dense: UnsignedTypedArray
8
8
  private sparse: UnsignedTypedArray
9
- #length = 0
9
+ private _length = 0
10
10
 
11
11
  get [Symbol.toStringTag](): string {
12
12
  return this.constructor.name
13
13
  }
14
14
 
15
15
  get size(): number {
16
- return this.#length
16
+ return this._length
17
17
  }
18
18
 
19
19
  constructor(array: UnsignedTypedArray<ArrayBuffer>) {
@@ -53,7 +53,7 @@ export class TypedSparseSet implements Iterable<number> {
53
53
  }
54
54
 
55
55
  * values(): IterableIterator<number> {
56
- for (let i = 0; i < this.#length; i++) {
56
+ for (let i = 0; i < this._length; i++) {
57
57
  yield this.dense[i]
58
58
  }
59
59
  }
@@ -61,14 +61,14 @@ export class TypedSparseSet implements Iterable<number> {
61
61
  has(value: number): boolean {
62
62
  const index = this.sparse[value]
63
63
  return index !== undefined
64
- && index < this.#length
64
+ && index < this._length
65
65
  && index < this.dense.length // 用于改善JIT优化.
66
66
  && this.dense[index] === value
67
67
  }
68
68
 
69
69
  add(value: number): void {
70
70
  if (!this.has(value)) {
71
- const index = this.#length++
71
+ const index = this._length++
72
72
  this.dense[index] = value
73
73
  this.sparse[value] = index
74
74
  }
@@ -78,11 +78,11 @@ export class TypedSparseSet implements Iterable<number> {
78
78
  const index = this.sparse[value]
79
79
  if (
80
80
  index !== undefined &&
81
- index < this.#length &&
81
+ index < this._length &&
82
82
  index < this.dense.length && // 用于改善JIT优化.
83
83
  this.dense[index] === value
84
84
  ) {
85
- const lastIndex = --this.#length
85
+ const lastIndex = --this._length
86
86
  const lastValue = this.dense[lastIndex]
87
87
  if (value !== lastValue) {
88
88
  this.dense[index] = lastValue
@@ -96,7 +96,7 @@ export class TypedSparseSet implements Iterable<number> {
96
96
  }
97
97
 
98
98
  clear(): void {
99
- this.#length = 0
99
+ this._length = 0
100
100
  // 无需清空dense和sparse数组.
101
101
  }
102
102
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-max-value-of-unsigned-typed-array.js","sourceRoot":"","sources":["../../src/utils/get-max-value-of-unsigned-typed-array.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,0CAA0C,CACxD,WAA0C;IAE1C,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,UAAU,CAAC;QAChB,KAAK,iBAAiB,CAAC,CAAC,OAAO,GAAG,CAAA;QAClC,KAAK,WAAW,CAAC,CAAC,OAAO,KAAK,CAAA;QAC9B,KAAK,WAAW,CAAC,CAAC,OAAO,UAAU,CAAA;QACnC,OAAO,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAAyB;IACvE,OAAO,0CAA0C,CAC/C,KAAK,CAAC,WAA4C,CACnD,CAAA;AACH,CAAC"}