HashMap

class HashMap : AbstractMap!(K, V)(
K
V
) {}

Constructors

this
this(int initialCapacity, float loadFactor)

Constructs an empty <tt>HashMap</tt> with the specified initial capacity and load factor.

this
this(int initialCapacity)

Constructs an empty <tt>HashMap</tt> with the specified initial capacity and the default load factor (0.75).

this
this()

Constructs an empty <tt>HashMap</tt> with the default initial capacity (16) and the default load factor (0.75).

this
this(Map!(K, V) m)

Constructs a new <tt>HashMap</tt> with the same mappings as the specified <tt>Map</tt>. The <tt>HashMap</tt> is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified <tt>Map</tt>.

this
this(V[K] m)
Undocumented in source.

Members

Aliases

remove
alias remove = AbstractMap!(K, V).remove
Undocumented in source.

Classes

KeyInputRange
class KeyInputRange
Undocumented in source.
ValueInputRange
class ValueInputRange
Undocumented in source.

Functions

afterNodeAccess
void afterNodeAccess(HashMapNode!(K, V) p)
Undocumented in source. Be warned that the author may not have intended to support it.
afterNodeInsertion
void afterNodeInsertion(bool evict)
Undocumented in source. Be warned that the author may not have intended to support it.
afterNodeRemoval
void afterNodeRemoval(HashMapNode!(K, V) p)
Undocumented in source. Be warned that the author may not have intended to support it.
byKey
InputRange!K byKey()

Returns a {@link Set} view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own <tt>remove</tt> operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> operations. It does not support the <tt>add</tt> or <tt>addAll</tt> operations.

byValue
InputRange!V byValue()
Undocumented in source. Be warned that the author may not have intended to support it.
clear
void clear()

Removes all of the mappings from this map. The map will be empty after this call returns.

containsKey
bool containsKey(K key)

Returns <tt>true</tt> if this map contains a mapping for the specified key.

containsValue
bool containsValue(V value)

Returns <tt>true</tt> if this map maps one or more keys to the specified value.

get
V get(K key)

Returns the value to which the specified key is mapped, or {@code null} if this map contains no mapping for the key.

getNode
HashMapNode!(K, V) getNode(size_t hash, K key)

Implements Map.get and related methods

newNode
HashMapNode!(K, V) newNode(size_t hash, K key, V value, HashMapNode!(K, V) next)
Undocumented in source. Be warned that the author may not have intended to support it.
newTreeNode
TreeNode!(K, V) newTreeNode(size_t hash, K key, V value, HashMapNode!(K, V) next)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(ref K, ref V) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(MapEntry!(K, V) entry) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
put
V put(K key, V value)

Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.

putMapEntries
void putMapEntries(Map!(K, V) m, bool evict)

Implements Map.putAll and Map constructor

putMapEntries
void putMapEntries(V[K] m, bool evict)
Undocumented in source. Be warned that the author may not have intended to support it.
putVal
V putVal(size_t hash, K key, V value, bool onlyIfAbsent, bool evict)

Implements Map.put and related methods

reinitialize
void reinitialize()

Reset to initial default state. Called by clone and readObject.

remove
V remove(K key)

Removes the mapping for the specified key from this map if present.

removeNode
HashMapNode!(K, V) removeNode(size_t hash, K key, V value, bool matchValue, bool movable)

Implements Map.remove and related methods

replacementNode
HashMapNode!(K, V) replacementNode(HashMapNode!(K, V) p, HashMapNode!(K, V) next)
Undocumented in source. Be warned that the author may not have intended to support it.
replacementTreeNode
TreeNode!(K, V) replacementTreeNode(HashMapNode!(K, V) p, HashMapNode!(K, V) next)
Undocumented in source. Be warned that the author may not have intended to support it.
resize
HashMapNode!(K, V)[] resize()

Initializes or doubles table size. If null, allocates in accord with initial capacity target held in field threshold. Otherwise, because we are using power-of-two expansion, the elements from each bin must either stay at same index, or move with a power of two offset in the new table.

treeifyBin
void treeifyBin(HashMapNode!(K, V)[] tab, size_t hash)

Replaces all linked nodes in bin at index for given hash unless table is too small, in which case resizes instead.

Mixins

__anonymous
mixin CloneMemberTemplate!(typeof(this), TopLevel.no, (typeof(this) from, typeof(this) to))

Returns a shallow copy of this {@code HashMap} instance: the keys and values themselves are not cloned.

Mixin templates

HashIterator
mixintemplate HashIterator()
Undocumented in source.

Variables

DEFAULT_INITIAL_CAPACITY
enum int DEFAULT_INITIAL_CAPACITY;

The default initial capacity - MUST be a power of two.

DEFAULT_LOAD_FACTOR
enum float DEFAULT_LOAD_FACTOR;

The load factor used when none specified in constructor.

MIN_TREEIFY_CAPACITY
enum int MIN_TREEIFY_CAPACITY;

The smallest table capacity for which bins may be treeified. (Otherwise the table is resized if too many nodes in a bin.) Should be at least 4 * TREEIFY_THRESHOLD to avoid conflicts between resizing and treeification thresholds.

TREEIFY_THRESHOLD
enum int TREEIFY_THRESHOLD;

The bin count threshold for using a tree rather than list for a bin. Bins are converted to trees when adding an element to a bin with at least this many nodes. The value must be greater than 2 and should be at least 8 to mesh with assumptions in tree removal about conversion back to plain bins upon shrinkage.

loadFactor
float loadFactor;

The load factor for the hash table.

modCount
int modCount;

The number of times this HashMap has been structurally modified Structural modifications are those that change the number of mappings in the HashMap or otherwise modify its internal structure (e.g., rehash). This field is used to make iterators on Collection-views of the HashMap fail-fast. (See ConcurrentModificationException).

table
HashMapNode!(K, V)[] table;

The table, initialized on first use, and resized as necessary. When allocated, length is always a power of two. (We also tolerate length zero in some operations to allow bootstrapping mechanics that are currently not needed.)

threshold
int threshold;

The next size value at which to resize (capacity * load factor).

Meta