Performance: repeated sweep through large binary dataset
You did not provide any performance measurements, so every answer here is basically guesswork, but I suspect that the lack of speed you are experiencing could have something to do with std::vector&lt;bool&gt;. 

The problem is that std::vector&lt;bool&gt; is not really what it appears to be. While a vector of any other type actually works in units of bytes, the specialization for bool works with individual bits, packing them as tightly as possible. This is, of course, great if you want to reduce memory usage, but it also is really slow since you have to mask and shift bits around every time you want to access a value. 

For this reason, in combination with the fact that it doesn't behave like a normal vector in certain cases (which are, sadly, not exactly rare), std::vector&lt;bool&gt; is mostly seen as a design flaw in the standard library and does not see much use. 

You should try to replace std::vector&lt;bool&gt; with a similar fitting type, e.g. std::vector&lt;char&gt;, and measure that to determine whether and by how much this alleviates your issue.

If you are not convinced yet, here is a quick-and-dirty benchmark to show just how much slower std::vector&lt;bool&gt; is.