I want to hide multiple elements in a valarray<int>
which has consecutive integers starting from 0. For example, from {0, 1, 2, 3, 4, 5}
to {0, 2, 3, 5}
. I have found that I can use indirect array
to specify elements indices with valarray<size_t>
. However, I don't know how to generate valarray<size_t>
with indices I want in O(1)
complexity. O(1)
complexity or at most O(logn)
complexity is very important to me. So, I think gslice
may be able to solve the problem, but I still can't figure out how to implement it.
Note: I use c++11