These are from algebra.Monoid
Returns an instance of
T calculated by summing all instances in iter in one pass.
Returns an instance of
T calculated by summing all instances in iter in one pass. Returns None if
iter is empty, else Some[
T].
instances of
T to be combined
None if iter is empty, else an option value containing the summed
T
A top-k monoid that is much faster than SortedListTake equivalent to: (left ++ right).sorted.take(k) but doesn't do a total sort If you can handle the mutability, mutable.PriorityQueueMonoid is even faster.
NOTE!!!! This assumes the inputs are already sorted! resorting each time kills speed