Wouldn't that essentially clone all the data in the vector in the first place? I'm trying to minimize memory by having an iterator implementation rather than another presorted data structure that clones the underlying data.
- Posts
- 3
- Comments
- 4
- Joined
- 1 yr. ago
- Posts
- 3
- Comments
- 4
- Joined
- 1 yr. ago
That's essentially where the code started, where the vector was presorted, then moved to a function to be used for a calculation. I want to have the caller be able to pass a borrow of a collection, for the purposes of this problem right now a fixed size vector, and not have to move the vector into the function. The function needs the sorted data, but doesn't need to clone any of the data, just needs to run a calculation over it. Ideally the final implementation can a) take a borrow to a fixed size vector and b) not clone any of the underlying data in order to run its own calculations. The solution I'm toying with now is a sorted iterator, which shouldn't clone the underlying vector's data and should traverse the fixed size vector in a sorted order. Having an iterator whose
nextreturns sorted items from the fixed size vector would be the perfect solution to this issue.