Skip to content

Commit e7cd960

Browse files
committed
---
yaml --- r: 184071 b: refs/heads/auto c: 404724b h: refs/heads/master i: 184069: 6257bbb 184067: e322e74 184063: 52bac36 v: v3
1 parent 8192804 commit e7cd960

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: e20e45567337215c82a3ffb1117982e7f7462a65
13+
refs/heads/auto: 404724be202c0a6f33d40df8450c11ee72684672
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libtest/stats.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
use std::cmp::Ordering::{self, Less, Greater, Equal};
1414
use std::collections::hash_map::Entry::{Occupied, Vacant};
15+
#[cfg(not(stage0))]
1516
use std::collections::hash_map;
17+
#[cfg(stage0)]
18+
use std::collections::hash_map::{self, Hasher};
1619
use std::hash::Hash;
1720
use std::mem;
1821
use std::num::{Float, FromPrimitive};
@@ -332,6 +335,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
332335

333336
/// Returns a HashMap with the number of occurrences of every element in the
334337
/// sequence that the iterator exposes.
338+
#[cfg(not(stage0))]
335339
pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
336340
where T: Iterator<Item=U>, U: Eq + Clone + Hash
337341
{
@@ -345,6 +349,22 @@ pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
345349
map
346350
}
347351

352+
/// Returns a HashMap with the number of occurrences of every element in the
353+
/// sequence that the iterator exposes.
354+
#[cfg(stage0)]
355+
pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
356+
where T: Iterator<Item=U>, U: Eq + Clone + Hash<Hasher>
357+
{
358+
let mut map: hash_map::HashMap<U,uint> = hash_map::HashMap::new();
359+
for elem in iter {
360+
match map.entry(elem) {
361+
Occupied(mut entry) => { *entry.get_mut() += 1; },
362+
Vacant(entry) => { entry.insert(1); },
363+
}
364+
}
365+
map
366+
}
367+
348368
// Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
349369

350370
#[cfg(test)]

0 commit comments

Comments
 (0)