I definitely agree that this function should not replace the current filter function. We can give it a new name like "partition" or something.
+1 on “partition”. That makes the semantics much clearer, IMHO.
Regarding the memory constraint: since both filter and partition methods will be provided, the developer may choose whether they prefer performance over memory fragmentation or not.
Or maybe at the end of the partition method, if one of the result arrays is significantly smaller than the other, we copy the data into a smaller array and then return.
Oh, yeah… I was thinking the excess storage would be deallocated at the end anyway. Honestly, this whole bit about super-optimizing the memory allocation assumes that the actual element storage is managed like C arrays (with a pointer to , and using pointer math to get the other elements) behind the scenes, and I don’t actually know that it’s done that way.
- Dave Sweeris
On Jan 15, 2016, at 11:49, Arman Shan <email@example.com> wrote: