title: Fast way of iterate over trues in boolean array
body: <p>I have a big array of booleans and i need just to work with the true elements, and need theyer index.</p>
  
  <pre><code>for (int x = 0; x &lt; cells.length; x++) {
          for (int y = 0; y &lt; cells[0].length; y++) {
  
                  if (cells[x][y]) {
                      g.fillRect(x * cellSize, y * cellSize, cellSize, cellSize);
                  }
  
          }
      }
  </code></pre>
  
  <p>so how can i do that without the two foor loops and save the time?</p>