If you ask me, I'd prefer to have the container cache things than forcing the user to do it.
That's correct. My point was to have a container instead of an iterator. The container can do the filtering while it is created, that's my point. However in my exact code, no such thing is done, the filtering is done on the fly.@wysota: I think I'm missing something, because your container looks like what I'm willing to do, but I don't see how you're filtering the content once: you return the iterator and intermediate result is not saved anywhere (it seems, but I don't know how the DOM works in Qt). From your code, it seems that every time you call the begin_const(), an iterator is built from the first element, and the filtering is done every time. In fact, you're retrieving the next element using
which is the actual filtering.Qt Code:
m_e = m_e.nextSiblingElement(m_t);To copy to clipboard, switch view to plain text mode
No, you cache filtering results, not the data. Say you have 100 elements in a container. When you iterate it for the first time, you can fill a bitmap with zeroes and ones marking whether a particular item meets the conditions or not. Then when you iterate again or when you go back, you can use the bitmap to avoid checking the data again.Caching of the result (to do the filtering once), would require saving the items you find in the iterator and use the saved copy until the original data is not changed.






Reply With Quote

Bookmarks