K - V - public class ArrayHashMap<K,V> extends DefaultHashMap<K,V> implements ListMap<K,V>
这个hash表的实现具有以下特性:
| 限定符和类型 | 类和说明 |
|---|---|
protected class |
ArrayHashMap.Entry
Map.Entry的实现.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 限定符和类型 | 字段和说明 |
|---|---|
protected DefaultHashMap.Entry<K,V>[] |
order
记录entry的顺序的数组.
|
loadFactor, modCount, size, table, threshold| 构造器和说明 |
|---|
ArrayHashMap()
创建一个空的hash表.
|
ArrayHashMap(int initialCapacity)
创建一个空的hash表.
|
ArrayHashMap(int initialCapacity,
float loadFactor)
创建一个空的hash表.
|
ArrayHashMap(Map<? extends K,? extends V> map)
复制指定Map内容相同的HashMap.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addEntry(K key,
V value)
此方法覆盖了父类的方法.
|
void |
clear()
清除hash表中的所有entry.
|
boolean |
containsValue(Object value)
如果hash表中包含一个或多个key对应指定的value, 则返回true.
|
List<Map.Entry<K,V>> |
entryList()
返回所有entry的List.
|
V |
get(int index)
返回指定index处的value.
|
K |
getKey(int index)
返回指定index处的key.
|
List<K> |
keyList()
返回所有key的List.
|
protected Iterator<Map.Entry<K,V>> |
newEntryIterator()
覆盖父类的方法, 用来创建entry的遍历器.
|
protected Iterator<K> |
newKeyIterator()
覆盖父类的方法, 用来创建key的遍历器.
|
protected Iterator<V> |
newValueIterator()
覆盖父类的方法, 用来创建value的遍历器.
|
protected void |
onInit()
初始化时hash表.
|
Map.Entry<K,V> |
removeEntry(int index)
删除指定index处的项.
|
protected void |
resize(int newCapacity)
对map进行扩容.
|
protected void |
transfer(DefaultHashMap.Entry<K,V>[] newTable)
基类在resize时会调用此方法把所有的项复制到新的数组中.
|
List<V> |
valueList()
返回所有value的List.
|
clone, containsKey, entrySet, eq, get, getCapacity, getEntry, getLoadFactor, getThreshold, hash, indexFor, isEmpty, keySet, put, putAll, remove, removeEntry, removeEntryForKey, size, valuesequals, hashCode, toStringcompute, computeIfAbsent, computeIfPresent, containsKey, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesprotected transient DefaultHashMap.Entry<K,V>[] order
public ArrayHashMap()
public ArrayHashMap(int initialCapacity)
initialCapacity - 初始容量.public ArrayHashMap(int initialCapacity,
float loadFactor)
initialCapacity - 初始容量loadFactor - 负载系数.public boolean containsValue(Object value)
containsValue 在接口中 Map<K,V>containsValue 在类中 DefaultHashMap<K,V>value - 指定value, 检查它的存在与否.public void clear()
public V get(int index)
public K getKey(int index)
public Map.Entry<K,V> removeEntry(int index)
removeEntry 在接口中 ListMap<K,V>index - 要删除的项的索引值protected void onInit()
onInit 在类中 DefaultHashMap<K,V>protected void addEntry(K key, V value)
addEntry 在类中 DefaultHashMap<K,V>key - hash表的keyvalue - hash表的valueprotected Iterator<K> newKeyIterator()
newKeyIterator 在类中 DefaultHashMap<K,V>protected Iterator<V> newValueIterator()
newValueIterator 在类中 DefaultHashMap<K,V>protected Iterator<Map.Entry<K,V>> newEntryIterator()
newEntryIterator 在类中 DefaultHashMap<K,V>protected void resize(int newCapacity)
resize 在类中 DefaultHashMap<K,V>newCapacity - 新的容量protected void transfer(DefaultHashMap.Entry<K,V>[] newTable)
transfer 在类中 DefaultHashMap<K,V>newTable - 新表Copyright © 2015. All rights reserved.