import { concreteSortedSet } from "@tsplus/stdlib/collections/SortedSet/_internal/SortedSetInternal" /** * Partition the values of a set using the specified predicate. * * @tsplus static SortedSet.Aspects partition * @tsplus pipeable SortedSet partition */ export function partition( f: Refinement ): (self: SortedSet) => readonly [SortedSet, SortedSet] export function partition( f: Predicate ): (self: SortedSet) => readonly [SortedSet, SortedSet] export function partition( f: Predicate ): (self: SortedSet) => readonly [SortedSet, SortedSet] { return (self) => { concreteSortedSet(self) let right = SortedSet.empty(self.keyTree.ord) let left = SortedSet.empty(self.keyTree.ord) for (const value of self) { if (f(value)) { right = right.add(value) } else { left = left.add(value) } } return [left, right] } }