Skip to content

Preserving order in Map and Set using doubly linked lists#706

Merged
Perryvw merged 11 commits intomasterfrom
feature/ordered-map-set
Aug 27, 2019
Merged

Preserving order in Map and Set using doubly linked lists#706
Perryvw merged 11 commits intomasterfrom
feature/ordered-map-set

Conversation

@Perryvw
Copy link
Copy Markdown
Member

@Perryvw Perryvw commented Aug 24, 2019

Code complicates a bit with the extra list bookkeeping. This does preserve O(1) insert and deletes. Iteration is still O(n), although it does include some extra table lookups, so probably more like O(2n) compared to the O(n) it was before.

@Perryvw Perryvw requested review from ark120202 and tomblind and removed request for tomblind August 24, 2019 14:33
expect(util.transpileAndExecute(`let m = new Map([[1,2],[3,4]]); m.delete(3); return m.size;`)).toBe(1);
});

const iterationMethods = ["entries", "keys", "values"];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrap all these new tests to a describe("iteration order", () => {}) block and remove preserves insertion order part in names?

@Perryvw Perryvw merged commit 0c65c0c into master Aug 27, 2019
@Perryvw Perryvw deleted the feature/ordered-map-set branch August 27, 2019 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants