algorithms
algorithms copied to clipboard
Fix `push` to be O(1) as promised.
The method comment says it is O(1) but the code was O(n). It was doing an unnecessary loop.
This reduces the time for the "Insertion then sort" benchmark from 7.659 to 0.011.
Fixes #36.
Related: https://github.com/kanwei/algorithms/pull/46 needs to be merged. It has the benchmark that I ran.
cc @alexkalderimis
Benchmark before this change (focus on top right number):

Benchmark after this change:
