Skip to content

Commit 176dbd1

Browse files
committed
---
yaml --- r: 125939 b: refs/heads/try c: fadbc0b h: refs/heads/master i: 125937: 1797b06 125935: 5769884 v: v3
1 parent c2e16e5 commit 176dbd1

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: f2fa55903e378368ed9173560f03a0ef16e371c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5-
refs/heads/try: 3f1c37e96da571e6eb8137aad1b5d65ea3f89a0b
5+
refs/heads/try: fadbc0b88bb39ac42aa4874e4a90df53a778ef59
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcollections/smallintmap.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use core::mem::replace;
2424
use {Collection, Mutable, Map, MutableMap, MutableSeq};
2525
use {vec, slice};
2626
use vec::Vec;
27+
use hash;
28+
use hash::Hash;
2729

2830
/// A map optimized for small integer keys.
2931
///
@@ -58,7 +60,7 @@ use vec::Vec;
5860
/// months.clear();
5961
/// assert!(months.is_empty());
6062
/// ```
61-
#[deriving(Hash, PartialEq, Eq)]
63+
#[deriving(PartialEq, Eq)]
6264
pub struct SmallIntMap<T> {
6365
v: Vec<Option<T>>,
6466
}
@@ -167,6 +169,12 @@ impl<V:Clone> Clone for SmallIntMap<V> {
167169
}
168170
}
169171

172+
impl <S: hash::Writer, T: Hash<S>> Hash<S> for SmallIntMap<T> {
173+
fn hash(&self, state: &mut S) {
174+
self.v.hash(state)
175+
}
176+
}
177+
170178
impl<V> SmallIntMap<V> {
171179
/// Create an empty SmallIntMap.
172180
///
@@ -478,8 +486,8 @@ pub type Values<'a, T> =
478486
#[cfg(test)]
479487
mod test_map {
480488
use std::prelude::*;
481-
use std::hash;
482489
use vec::Vec;
490+
use hash;
483491

484492
use {Map, MutableMap, Mutable, MutableSeq};
485493
use super::SmallIntMap;
@@ -764,19 +772,19 @@ mod test_map {
764772

765773
#[test]
766774
fn test_hash() {
767-
let mut x = SmallIntMap::new();
768-
let mut y = SmallIntMap::new();
775+
let mut x = SmallIntMap::new();
776+
let mut y = SmallIntMap::new();
769777

770-
assert!(hash::hash(&x) == hash::hash(&y));
771-
x.insert(1, 'a');
772-
x.insert(2, 'b');
773-
x.insert(3, 'c');
778+
assert!(hash::hash(&x) == hash::hash(&y));
779+
x.insert(1, 'a');
780+
x.insert(2, 'b');
781+
x.insert(3, 'c');
774782

775-
y.insert(3, 'c');
776-
y.insert(2, 'b');
777-
y.insert(1, 'a');
783+
y.insert(3, 'c');
784+
y.insert(2, 'b');
785+
y.insert(1, 'a');
778786

779-
assert!(hash::hash(&x) == hash::hash(&y));
787+
assert!(hash::hash(&x) == hash::hash(&y));
780788
}
781789

782790
#[test]

0 commit comments

Comments
 (0)