这是它的源码:
public boolean containsValue(Object value) { Node<K,V>[] tab; V v; if ((tab = table) != null && size > 0) { for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) { if ((v = e.value) == value || (value != null && value.equals(v))) return true; } } } return false; }
是在遍历数组里先得到头节点,然后再遍历链表得到value,,时间复杂度是O(n)还是O(n²)
30秒到达战场
相关分类