Thank you ggggg, that is very helpful and provided me with what I needed to know. The key insight is to move the lookup of the next active element to the state calculation like they did in what you linked.
Steven, thank you for the link to filter. I am not sure if I can use it straight off the standard library because my use case is a bit more complicated than I wrote in my original post. I tried doing something similar to what filter is doing but right now it is too slow to be usable. Since this is in a very tight loop I am guessing the tuple allocations are dragging down the performance. I am currently on a pre tuple rework commit so it might be better after I update. Thanks for your help again, both of you. On Friday, May 1, 2015 at 10:26:38 PM UTC+2, Steven G. Johnson wrote: > > > > On Friday, May 1, 2015 at 3:07:03 PM UTC-4, Kristoffer Carlsson wrote: >> >> Let's say I want to implement an iterator over a vector of objects and >> only return (or yield) the objects that have some sort property. >> > > What you're describing is the filter iterator, which is already > implemented in the Julia standard library. If you want to know how to do > it, see: > > > https://github.com/JuliaLang/julia/blob/37041bb039b33dfe2ae02a6f17f8f9639df94c5d/base/iterator.jl#L58-L96 > > > For example, Filter(iseven, A) returns an iterator over only the > even-valued elements of some array A of integers. >
