Skip to content

Commit 8be9300

Browse files
committed
Removed GroupingMap::count and related tests, has been replaced by Itertools::counts in #468
1 parent 0e5dc21 commit 8be9300

File tree

2 files changed

+0
-47
lines changed

2 files changed

+0
-47
lines changed

src/grouping_map.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -215,33 +215,6 @@ impl<I, K, V> GroupingMap<I>
215215
destination_map
216216
}
217217

218-
/// Groups elements from the `GroupingMap` source by key and counts them.
219-
///
220-
/// Return a `HashMap` associating the key of each group with the number of that group's elements.
221-
///
222-
/// ```
223-
/// use itertools::Itertools;
224-
///
225-
/// let lookup = "This is a string".chars()
226-
/// .into_grouping_map_by(|&c| c)
227-
/// .count();
228-
///
229-
/// assert_eq!(lookup[&'T'], 1);
230-
/// assert_eq!(lookup[&'h'], 1);
231-
/// assert_eq!(lookup[&'i'], 3);
232-
/// assert_eq!(lookup[&'s'], 3);
233-
/// assert_eq!(lookup[&' '], 3);
234-
/// assert_eq!(lookup[&'a'], 1);
235-
/// assert_eq!(lookup[&'t'], 1);
236-
/// assert_eq!(lookup[&'r'], 1);
237-
/// assert_eq!(lookup[&'n'], 1);
238-
/// assert_eq!(lookup[&'g'], 1);
239-
/// assert_eq!(lookup.len(), 10);
240-
/// ```
241-
pub fn count(self) -> HashMap<K, usize> {
242-
self.fold(0, |acc, _, _| acc + 1)
243-
}
244-
245218
/// Groups elements from the `GroupingMap` source by key and finds the maximum of each group.
246219
///
247220
/// If several elements are equally maximum, the last element is picked.

tests/quick.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,26 +1303,6 @@ quickcheck! {
13031303
assert_eq!(lookup_grouping_map, lookup_group_map);
13041304
}
13051305

1306-
fn correct_grouping_map_by_count_modulo_key(a: Vec<u8>, modulo: u8) -> () {
1307-
let modulo = if modulo == 0 { 1 } else { modulo }; // Avoid `% 0`
1308-
let count = a.len();
1309-
let lookup = a.iter().copied().into_grouping_map_by(|i| i % modulo).count();
1310-
1311-
let group_map_lookup = a.iter().copied()
1312-
.map(|i| (i % modulo, i))
1313-
.into_group_map()
1314-
.into_iter()
1315-
.map(|(key, vals)| (key, vals.len()))
1316-
.collect::<HashMap<_,_>>();
1317-
assert_eq!(lookup, group_map_lookup);
1318-
1319-
assert_eq!(lookup.values().sum::<usize>(), count);
1320-
1321-
for (&key, &count) in lookup.iter() {
1322-
assert_eq!(count, a.iter().filter(|&val| val % modulo == key).count());
1323-
}
1324-
}
1325-
13261306
fn correct_grouping_map_by_max_modulo_key(a: Vec<u8>, modulo: u8) -> () {
13271307
let modulo = if modulo == 0 { 1 } else { modulo }; // Avoid `% 0`
13281308
let lookup = a.iter().copied().into_grouping_map_by(|i| i % modulo).max();

0 commit comments

Comments
 (0)