title: Time Complexity of HashMap methods
body: <p>Since i'm working around time complexity, i've been searching through the oracle Java class library for the time complexity of some standard methods used on Lists, Maps and Classes. (more specifically, ArrayList, HashSet and HashMap)</p>
  
  <p>Now, when looking at the <a href="http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html" rel="noreferrer">HashMap javadoc page</a>, they only really speak about the <code>get()</code> and <code>put()</code> methods.</p>
  
  <p>The methods i still need to know are:</p>
  
  <pre><code>remove(Object o)
  size()
  values()
  </code></pre>
  
  <p>I think that <code>remove()</code> will be the same complexity as <code>get()</code>, <code>O(1)</code>, assuming we don't have a giant HashMap with equal hashCodes, etc etc...</p>
  
  <p>For <code>size()</code> i'd also assume <code>O(1)</code>, since a HashSet, which also has no order, has a <code>size()</code> method with complexity <code>O(1)</code>.</p>
  
  <p>The one i have no idea of is <code>values()</code> - I'm not sure whether this method will just somehow "copy" the HashMap, giving a time complexity of <code>O(1)</code>, or if it will have to iterate over the HashMap, making the complexity equal to the amount of elements stored in the HashMap.</p>
  
  <p>Thanks.</p>