Skip to content

Commit 5cb1e16

Browse files
TakeshiCopilot
andcommitted
fix: prevent remove() crash on stale undefined/zero slots in all PQ types
- PriorityQueue.remove(): add node && null-guard in findIndex (fixes TypeError crash when _elements contains undefined slots from prior dequeue/pop or _grow calls) - TypedPriorityQueue.remove(): replace findIndex with bounded loop limited to _size to avoid matching stale zero-filled slots - StableTypedPriorityQueue.remove(): same bounded-loop fix - TypedPriorityQueue.indexOf() and StableTypedPriorityQueue.indexOf(): same bounded-loop fix for consistency - Add regression tests for dequeue-then-remove across all 4 PQ types - Regenerate docs Co-authored-by: Copilot <[email protected]>
1 parent a65f023 commit 5cb1e16

150 files changed

Lines changed: 1107 additions & 1225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/all_symbols.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
</div>
3535
</nav>
3636
<div id="searchResults"></div><div id="content">
37-
<main><div class="space-y-7" id=""><section class="section" id="default">
38-
<div>
39-
<h2 class="anchorable mb-1"><a href="#default" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
37+
<main><div class="space-y-7" id=""><section class="section" id="default"><div>
38+
<h2 class="anchorable mb-1"><a href="#default" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
4039
width="16"
4140
height="16"
4241
viewBox="0 0 14 14"

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
</div>
2727
</nav>
2828
<div id="searchResults"></div><div id="content">
29-
<main><section >
30-
<div class="space-y-2 flex-1 "><div class="space-y-7" id="module_doc"></div>
29+
<main><section>
30+
<div class="space-y-2 flex-1"><div class="space-y-7" id="module_doc"></div>
3131
</div>
3232
</section>
3333
</main><div class="toc">

docs/search_index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/~/ARITY.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<span class="text-Variable">variable</span>&nbsp;<span class="font-bold">ARITY</span>
4141
</div></div><a
4242
class="context_button relative mr-2"
43-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;primitive.ts"><svg
43+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;primitive.ts"><svg
4444
width="14"
4545
height="14"
4646
viewBox="0 0 14 14"
@@ -64,9 +64,8 @@
6464
</svg>
6565
</a>
6666
</div><div><div class="space-y-7" id=""><div class="markdown"><p>The arity of the heap. This is the number of children each node has.</p>
67-
</div><section class="section" id="type">
68-
<div>
69-
<h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
67+
</div><section class="section" id="type"><div>
68+
<h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
7069
width="16"
7170
height="16"
7271
viewBox="0 0 14 14"
@@ -95,7 +94,7 @@ <h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" t
9594
</code>
9695
</div><a
9796
class="context_button relative mr-2"
98-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;primitive.ts"><svg
97+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;primitive.ts"><svg
9998
width="14"
10099
height="14"
101100
viewBox="0 0 14 14"

docs/~/IComparer.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<span class="text-TypeAlias">type alias</span>&nbsp;<span class="font-bold">IComparer</span>
4141
</div></div><a
4242
class="context_button relative mr-2"
43-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
43+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
4444
width="14"
4545
height="14"
4646
viewBox="0 0 14 14"
@@ -64,9 +64,8 @@
6464
</svg>
6565
</a>
6666
</div><div><div class="space-y-7" id=""><div class="markdown"><p>A type representing a comparison function that determines the order of two elements.</p>
67-
</div><section class="section" id="type-parameters">
68-
<div>
69-
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
67+
</div><section class="section" id="type-parameters"><div>
68+
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
7069
width="16"
7170
height="16"
7271
viewBox="0 0 14 14"
@@ -117,7 +116,7 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
117116
</code>
118117
</div><a
119118
class="context_button relative mr-2"
120-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
119+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
121120
width="14"
122121
height="14"
123122
viewBox="0 0 14 14"
@@ -145,9 +144,8 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
145144
</ul>
146145
</div></div></div>
147146
</div></section>
148-
<section class="section" id="definition">
149-
<div>
150-
<h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
147+
<section class="section" id="definition"><div>
148+
<h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
151149
width="16"
152150
height="16"
153151
viewBox="0 0 14 14"
@@ -176,7 +174,7 @@ <h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anc
176174
</code>
177175
</div><a
178176
class="context_button relative mr-2"
179-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
177+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
180178
width="14"
181179
height="14"
182180
viewBox="0 0 14 14"

docs/~/IEqualityComparator.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<span class="text-TypeAlias">type alias</span>&nbsp;<span class="font-bold">IEqualityComparator</span>
4141
</div></div><a
4242
class="context_button relative mr-2"
43-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
43+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
4444
width="14"
4545
height="14"
4646
viewBox="0 0 14 14"
@@ -64,9 +64,8 @@
6464
</svg>
6565
</a>
6666
</div><div><div class="space-y-7" id=""><div class="markdown"><p>A type representing a function that compares two values for equality.</p>
67-
</div><section class="section" id="type-parameters">
68-
<div>
69-
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
67+
</div><section class="section" id="type-parameters"><div>
68+
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
7069
width="16"
7170
height="16"
7271
viewBox="0 0 14 14"
@@ -117,7 +116,7 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
117116
</code>
118117
</div><a
119118
class="context_button relative mr-2"
120-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
119+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
121120
width="14"
122121
height="14"
123122
viewBox="0 0 14 14"
@@ -143,9 +142,8 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
143142
</div><div class="max-w-[75ch]"><div class="markdown"><p>The type of values being compared</p>
144143
</div></div></div>
145144
</div></section>
146-
<section class="section" id="definition">
147-
<div>
148-
<h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
145+
<section class="section" id="definition"><div>
146+
<h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
149147
width="16"
150148
height="16"
151149
viewBox="0 0 14 14"
@@ -174,7 +172,7 @@ <h2 class="anchorable mb-1"><a href="#definition" class="anchor" aria-label="Anc
174172
</code>
175173
</div><a
176174
class="context_button relative mr-2"
177-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
175+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
178176
width="14"
179177
height="14"
180178
viewBox="0 0 14 14"

docs/~/INode.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<span class="text-Interface">interface</span>&nbsp;<span class="font-bold">INode</span>
4141
</div></div><a
4242
class="context_button relative mr-2"
43-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
43+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
4444
width="14"
4545
height="14"
4646
viewBox="0 0 14 14"
@@ -64,9 +64,8 @@
6464
</svg>
6565
</a>
6666
</div><div><div class="space-y-7" id=""><div class="markdown"><p>Represents a basic node in a data structure.</p>
67-
</div><section class="section" id="type-parameters">
68-
<div>
69-
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
67+
</div><section class="section" id="type-parameters"><div>
68+
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
7069
width="16"
7170
height="16"
7271
viewBox="0 0 14 14"
@@ -117,7 +116,7 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
117116
</code>
118117
</div><a
119118
class="context_button relative mr-2"
120-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
119+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
121120
width="14"
122121
height="14"
123122
viewBox="0 0 14 14"
@@ -142,9 +141,8 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
142141
</a>
143142
</div></div>
144143
</div></section>
145-
<section class="section" id="properties">
146-
<div>
147-
<h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
144+
<section class="section" id="properties"><div>
145+
<h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
148146
width="16"
149147
height="16"
150148
viewBox="0 0 14 14"
@@ -195,7 +193,7 @@ <h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anc
195193
</code>
196194
</div><a
197195
class="context_button relative mr-2"
198-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
196+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
199197
width="14"
200198
height="14"
201199
viewBox="0 0 14 14"

docs/~/INode.value.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<span class="text-Property">property</span>&nbsp;<span class="font-bold">INode.value</span>
4141
</div></div><a
4242
class="context_button relative mr-2"
43-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
43+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
4444
width="14"
4545
height="14"
4646
viewBox="0 0 14 14"
@@ -63,9 +63,8 @@
6363
/>
6464
</svg>
6565
</a>
66-
</div><div><div class="space-y-7" id=""><section class="section" id="type">
67-
<div>
68-
<h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
66+
</div><div><div class="space-y-7" id=""><section class="section" id="type"><div>
67+
<h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
6968
width="16"
7069
height="16"
7170
viewBox="0 0 14 14"
@@ -94,7 +93,7 @@ <h2 class="anchorable mb-1"><a href="#type" class="anchor" aria-label="Anchor" t
9493
</code>
9594
</div><a
9695
class="context_button relative mr-2"
97-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
96+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
9897
width="14"
9998
height="14"
10099
viewBox="0 0 14 14"

docs/~/IPriorityNode.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<span class="type"> extends </span><a href="../././~/INode.html" class="link">INode</a>&lt;<a href="#type_param_T" class="link">T</a>&gt;</div>
4343
</div></div><a
4444
class="context_button relative mr-2"
45-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
45+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
4646
width="14"
4747
height="14"
4848
viewBox="0 0 14 14"
@@ -66,9 +66,8 @@
6666
</svg>
6767
</a>
6868
</div><div><div class="space-y-7" id=""><div class="markdown"><p>Represents a node in a priority queue that extends a basic Node type with priority information.</p>
69-
</div><section class="section" id="type-parameters">
70-
<div>
71-
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
69+
</div><section class="section" id="type-parameters"><div>
70+
<h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
7271
width="16"
7372
height="16"
7473
viewBox="0 0 14 14"
@@ -119,7 +118,7 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
119118
</code>
120119
</div><a
121120
class="context_button relative mr-2"
122-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
121+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
123122
width="14"
124123
height="14"
125124
viewBox="0 0 14 14"
@@ -145,9 +144,8 @@ <h2 class="anchorable mb-1"><a href="#type-parameters" class="anchor" aria-label
145144
</div><div class="max-w-[75ch]"><div class="markdown"><p>The type of value stored in the node</p>
146145
</div></div></div>
147146
</div></section>
148-
<section class="section" id="properties">
149-
<div>
150-
<h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
147+
<section class="section" id="properties"><div>
148+
<h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anchor" tabIndex="-1"><svg
151149
width="16"
152150
height="16"
153151
viewBox="0 0 14 14"
@@ -198,7 +196,7 @@ <h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anc
198196
</code>
199197
</div><a
200198
class="context_button relative mr-2"
201-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
199+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
202200
width="14"
203201
height="14"
204202
viewBox="0 0 14 14"
@@ -251,7 +249,7 @@ <h2 class="anchorable mb-1"><a href="#properties" class="anchor" aria-label="Anc
251249
</code>
252250
</div><a
253251
class="context_button relative mr-2"
254-
href="file:&#x2F;&#x2F;&#x2F;C:&#x2F;Users&#x2F;iwata&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
252+
href="file:&#x2F;&#x2F;&#x2F;Users&#x2F;tak&#x2F;Documents&#x2F;Development&#x2F;GitHub&#x2F;pq-ts&#x2F;src&#x2F;types.ts"><svg
255253
width="14"
256254
height="14"
257255
viewBox="0 0 14 14"

0 commit comments

Comments
 (0)