Skip to content

Commit 30d704d

Browse files
Document some OpenHashMap internal methods.
1 parent 1fb32fc commit 30d704d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/library/scala/collection/mutable/OpenHashMap.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ extends AbstractMap[Key, Value]
8181
h ^ (h >>> 7) ^ (h >>> 4)
8282
}
8383

84+
/** Increase the size of the table.
85+
* Copy only the occupied slots, effectively eliminating the deleted slots.
86+
*/
8487
private[this] def growTable() = {
8588
val oldSize = mask + 1
8689
val newSize = 4 * oldSize
@@ -92,8 +95,18 @@ extends AbstractMap[Key, Value]
9295
deleted = 0
9396
}
9497

98+
/** Return the index of the first slot in the hash table (in probe order)
99+
* that either is empty, or is or was last occupied by the given key.
100+
*/
95101
private[this] def findIndex(key: Key) : Int = findIndex(key, hashOf(key))
96102

103+
/** Return the index of the first slot in the hash table (in probe order)
104+
* that either is empty, or is or was last occupied by the given key.
105+
*
106+
* This method is an optimization for when the hash value is in hand.
107+
*
108+
* @param hash hash value for `key`
109+
*/
97110
private[this] def findIndex(key: Key, hash: Int): Int = {
98111
var j = hash
99112

0 commit comments

Comments
 (0)