Skip to content

Commit 549d80a

Browse files
committed
Hashing not too broken now
Still need to do expansion with bulk inserts + check deletes
1 parent 5e3f5a2 commit 549d80a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/algorithms/controllers/HashingInsertion.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ export default {
310310
let inserts = {};
311311
let bulkInsertions = 0;
312312
let prevTable = [...table];
313+
//XXX replace by expandAndReinsert
313314
const limit = () => {
314315
if (params.expand && table.length < LARGE_SIZE) return total + 1 === Math.round(table.length * 0.8);
315316
return total === table.length - 1;
@@ -648,7 +649,7 @@ export default {
648649
// Preparation for bulk insertion
649650
chunker.add(
650651
IBookmarks.BulkInsert,
651-
(vis, insertions, prevIdx) => {
652+
(vis, insertions, prevIdx, table) => {
652653
vis.array.unfill(INDEX, 0, undefined, table.length - 1); // Reset any coloring of slots
653654
vis.array.showKth({key: item, type: HASH_TYPE.BulkInsert, insertions: insertions, increment: ""});
654655
if (table.length <= PRIMES[POINTER_CUT_OFF])
@@ -661,13 +662,14 @@ export default {
661662
vis.graph.updateNode(HASH_GRAPH.Value2, ' ');
662663
}
663664
},
664-
[insertions, prevIdx]
665+
[insertions, prevIdx, table]
665666
)
666667
prevIdx = hashBulkInsert(table, translateInput(item, "Array"));
667668
}
668669
}
669670

670671
// when table is full or almost full
672+
//XXX get rid of this when we add expandAndReinsert to bulkInsert
671673
if (prevIdx === FULL_SIGNAL) {
672674
lastInput = i;
673675
[table, indexArr, valueArr, nullArr] = expandAndReinsert(table, 1);

src/algorithms/pseudocode/HashingInsertion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ const main = `
149149
InsertAll
150150
For each key k1 in OldT \\B 31
151151
\\In{
152-
// We call HashInsert recursively!
152+
HashInsert(T, k1) // recursive! \\B 32
153153
\\Expl{ There will never be multiple levels of
154154
recursion because the new table will be large enough
155155
to easily accomodate all the keys that were in T.
156+
We don't animate the details of these insertions.
156157
\\Expl}
157-
HashInsert(T, k1) \\B 32
158158
\\Note{ Animation can stop at this line for each
159159
key
160160
\\Note}

0 commit comments

Comments
 (0)