Skip to content

Commit 4b704ac

Browse files
committed
improve comments
1 parent ed0e13f commit 4b704ac

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/libstd/map.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ A hashmap
99
/*
1010
Type: hashfn
1111
12-
A function that returns a hash of a value
12+
A function that returns a hash of a value.
13+
The hash should concentrate entropy in the
14+
lower bits.
1315
*/
1416
type hashfn<K> = fn(K) -> uint;
1517

@@ -352,9 +354,15 @@ mod chained {
352354
}
353355

354356
/*
355-
Function: mk_hashmap
357+
Function: mk_flat_hashmap
358+
359+
Construct a "flat" hashmap, meaning that there are
360+
not chains per buckets, but rather we search a sequence
361+
of buckets for each key.
356362
357-
Construct a hashmap
363+
Warning: it is unclear to me that this code is correct
364+
on 32-bit processors. Check out the 'hash-tearing' code
365+
in hash() and the comment surrounding it. - Niko
358366
359367
Parameters:
360368
@@ -550,6 +558,16 @@ fn mk_flat_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
550558
ret hashmap(hasher, eqer, bkts, initial_capacity, 0u, load_factor);
551559
}
552560

561+
/*
562+
Function: mk_hashmap
563+
564+
Construct a hashmap.
565+
566+
Parameters:
567+
568+
hasher - The hash function for key type K
569+
eqer - The equality function for key type K
570+
*/
553571
fn mk_hashmap<copy K, copy V>(hasher: hashfn<K>, eqer: eqfn<K>)
554572
-> hashmap<K, V> {
555573
ret chained::mk(hasher, eqer);

0 commit comments

Comments
 (0)