title: Iterator isEmpty() call causing noSuchElement exception?
body: <p>I currently have the following code</p>
  
  <pre><code>while (!visibleTiles.isEmpty())) {
      tile = visibleTiles.keySet().iterator().next();
      if (tile != null){
          bitmap = visibleTiles.remove(tile);
          if(bitmap != null &amp;&amp; !containsKey(tile)){ //safe to recycle if tile cache is not actively holding it
              bitmap.recycle();
          }
      }
  }
  </code></pre>
  
  <p>However, I get a NoSuchElementException crash on the line</p>
  
  <pre><code>tile = visibleTiles.keySet().iterator().next();
  </code></pre>
  
  <p>Is there a big difference in using the isEmpty() method and calling a hasNext() call? I know that hashmaps do not have a hasNext() call so I did the following:</p>
  
  <pre><code>while (visibleTiles.keySet().iterator().hasNext()) {
      tile = visibleTiles.keySet().iterator().next();
      if (tile != null){
          bitmap = visibleTiles.remove(tile);
          if(bitmap != null &amp;&amp; !containsKey(tile)){ //safe to recycle if tile cache is not actively holding it
              bitmap.recycle();
          }
      }
  }
  </code></pre>
  
  <p>Obviously, I know that I should just run the app and see if it crashes, but the issue is that it's difficult to reproduce the problem.</p>
  
  <p>Thanks!</p>