montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.1k stars 184 forks source link

Resolve stack overflow in SortedSet.reduce and reduceRight #244

Open alex-dunn opened 3 years ago

alex-dunn commented 3 years ago

closes #150, Resolve stack overflow for SortedSet reduce & reduceRight

Replace recursive implementation with version that uses the Iterator. The limit in size of the set now seems to be whenever the browser runs out of memory to allocate for the main tree + the history tree in splay. Updated the Iterator to take a 4th argument: reverse. If reverse is falsey then behaviour is the same as master, otherwise it will iterator through the set in the reverse order.

hthetiot commented 3 years ago

Possible duplicate https://github.com/montagejs/collections/commit/85f00f8776e8ece7a6dbb43c47e489d0b14eaca6

hthetiot commented 3 years ago

Fix confirmed on master via this comment https://github.com/montagejs/collections/issues/241#issuecomment-789766305