title: Converting a HashMap to a Sorted TreeMap
body: <p>I have a HashMap which contains String as key , and an Object as value In order to sort my HashMap I create a TreeMap , iterate over the HashMap and put each entry of the HashMap into a TreeMap where key is bandwidth and value the instance of signal.Here is my code</p>
  
  <pre><code>public void createSortedSet(HashMap&lt;String, Signal&gt; map, long totalSize) {
  TreeMap&lt;Float, Signal&gt; sortedMap = new TreeMap&lt;Float, Signal&gt;();
  JOptionPane.showMessageDialog(null, map.size());
     try {
  
      final Iterator&lt;String&gt; iterator = map.keySet().iterator();
      while (iterator.hasNext()) {
          String messageName = iterator.next();
          Signal signal = map.get(messageName);
          signal.setBandwidth((signal.getSize() / (float) totalSize) * 100);
          sortedMap.put(signal.getBandwidth(), signal);
      }
      JOptionPane.showMessageDialog(null, sortedMap.size());
  
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  </code></pre>
  
  <p>The problem here is the size of map is 8318 while after the while loop when I check the size of TreeMap it gives 455?? Does it mean that not all the instances of the signal are stored in TreeMap</p>
  
  <p>Any Help ?</p>