title: Remove TreeMap entries less than x
body: <p><strong>I have the following TreeMap:</strong></p>
  
  <pre><code>private Map&lt;Date,WeekSchedule&gt; weeks = new TreeMap&lt;Date,WeekSchedule&gt;();
  </code></pre>
  
  <p><strong>And I need to remove all entries, whose date is before a given value.</strong> </p>
  
  <p>What is the most efficient way to do this?</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>public void removeWeeksBefore(Date monDate){
      for (Map.Entry&lt;Date, WeekSchedule&gt; entry : weeks.entrySet()){
          if(entry.getKey().before(monDate)){
              weeks.remove(entry.getKey());   //This will destroy the iterator
          }else{
              return;
          }
      }
  }
  </code></pre>