Sampling uniformly from entities in a query #664
Unanswered
CharlesJQuarra
asked this question in
Q&A
Replies: 1 comment
-
Did you find an answer to your question? If not can you provide a bit more information about what you are trying to do. My guess based on your description of storing the entity id's in a vector is you should use the f.iter([](flecs::iter& it) {
for (size_t i = 0; i < it.count(); i++) {
flecs::entity e = it.entity(i);
// Do stuff with the entity
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, forgive me if the question is too basic or is already explained somewhere. I've been searching for this on the queries documentation and I couldn't find the answer
Basically I want O(k) access (let's pretend page faults are irrelevant/not a bottleneck for this) to an uniformly sampled batch of k entities (with replacement, sampling without replacement is harder) that should be accessible from a given query.
Right now the only way I've found to implement this is to loop at least once on a query with
each
, store the entity ids on a std::vector, and sample from there. Let me know if there is a way to avoid this extra setup (or at the very least, know the size of the query set beforehand, so I can reserve enough memory when initializing thestd::vector
)Beta Was this translation helpful? Give feedback.
All reactions