title: FindBugs warning: Inefficient use of keySet iterator
body: <p>This a a similar question to [<a href="https://stackoverflow.com/questions/12639259/findbugs-warning-inefficient-use-of-keyset-iterator-instead-of-entryset-iterato][1]">FindBugs warning: Inefficient use of keySet iterator instead of entrySet iterator</a></p>
  
  <p>However, there I am trying to do something a little different. My current code is here: </p>
  
  <pre><code>for (Double key2 : sortedPolygons.keySet()) {
      if (sortedPolygons.get(key2).getExteriorRing().equals(hole)) {
          sortedPolygons.remove(key2);
          break;
      }
  }
  </code></pre>
  
  <p>Doing something like the solution in the link does not work. Here is an implementation of said solution:</p>
  
  <pre><code>for(Map.Entry&lt;Double, Polygon&gt; entry : sortedPolygons.entrySet()) {
      if (entry.getValue().getExteriorRing().equals(hole)) {
           .....
  </code></pre>
  
  <p>The problem here is that I am trying to <em>delete</em> the entry. There is no <code>entry.remove()</code>. How can I replace my first block of code, without the FindBugs error: </p>
  
  <blockquote>
    <p><strong>Inefficient use of keySet iterator instead of entrySet iterator</strong> -></p>
    
    <p>This method accesses the value of a Map entry, using a key that was
    retrieved from a keySet iterator. It is more efficient to use an
    iterator on the entrySet of the map, to avoid the Map.get(key) lookup.</p>
  </blockquote>
  
  <p>To note, the underlying structure is <code>TreeMap</code>, and it cannot be changed.</p>