diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-05-28 16:35:52 -0500 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-05-30 01:02:55 -0500 |
| commit | 007651cd267ee8af88384d968183a1dee0265919 (patch) | |
| tree | dac8928949cf8c96c6d546f3a0a4b592f0ab9ee9 /src/libstd/hashmap.rs | |
| parent | 4a5d887b58ff9833a968e7a0d28282b915e01de8 (diff) | |
| download | rust-007651cd267ee8af88384d968183a1dee0265919.tar.gz rust-007651cd267ee8af88384d968183a1dee0265919.zip | |
Require documentation by default for libstd
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.
Diffstat (limited to 'src/libstd/hashmap.rs')
| -rw-r--r-- | src/libstd/hashmap.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index e6ccb7a1d6b..72f92bc1522 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -34,6 +34,14 @@ struct Bucket<K,V> { value: V, } +/// A hash map implementation which uses linear probing along with the SipHash +/// hash function for internal state. This means that the order of all hash maps +/// is randomized by keying each hash map randomly on creation. +/// +/// It is required that the keys implement the `Eq` and `Hash` traits, although +/// this can frequently be achieved by just implementing the `Eq` and +/// `IterBytes` traits as `Hash` is automatically implemented for types that +/// implement `IterBytes`. pub struct HashMap<K,V> { priv k0: u64, priv k1: u64, @@ -53,6 +61,7 @@ fn resize_at(capacity: uint) -> uint { ((capacity as float) * 3. / 4.) as uint } +/// Creates a new hash map with the specified capacity. pub fn linear_map_with_capacity<K:Eq + Hash,V>( initial_capacity: uint) -> HashMap<K, V> { let mut r = rand::task_rng(); @@ -539,6 +548,9 @@ impl<K:Hash + Eq,V:Eq> Eq for HashMap<K, V> { fn ne(&self, other: &HashMap<K, V>) -> bool { !self.eq(other) } } +/// An implementation of a hash set using the underlying representation of a +/// HashMap where the value is (). As with the `HashMap` type, a `HashSet` +/// requires that the elements implement the `Eq` and `Hash` traits. pub struct HashSet<T> { priv map: HashMap<T, ()> } |
