Lines Matching defs:count
51 assert!(m.iter().count() == 128);
59 assert!(m.iter_mut().count() == 128);
67 assert!(m.iter().rev().count() == 128);
75 assert!(m.iter_mut().rev().count() == 128);
84 b.iter(|| s.chars().count());
107 b.iter(|| s.chars().count());
114 b.iter(|| s.chars().rev().count());
131 let len = s.chars().count();
133 b.iter(|| assert_eq!(s.char_indices().count(), len));
139 let len = s.chars().count();
141 b.iter(|| assert_eq!(s.char_indices().rev().count(), len));
148 b.iter(|| assert_eq!(s.split('V').count(), 3));
154 let len = s.split(' ').count();
156 b.iter(|| assert_eq!(s.split(' ').count(), len));
162 let len = s.split(' ').count();
167 b.iter(|| assert_eq!(s.split(pred).count(), len));
173 let len = s.split(' ').count();
175 b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
181 let len = s.split(' ').count();
184 b.iter(|| assert_eq!(s.split(c).count(), len));
341 make_test!(chars_count, s, s.chars().count());
346 make_test!(match_indices_a_str, s, s.match_indices("a").count());
348 make_test!(split_a_str, s, s.split("a").count());
369 make_test!(split_space_char, s, s.split(' ').count());
370 make_test!(split_terminator_space_char, s, s.split_terminator(' ').count());
372 make_test!(splitn_space_char, s, s.splitn(10, ' ').count());
373 make_test!(rsplitn_space_char, s, s.rsplitn(10, ' ').count());
375 make_test!(split_space_str, s, s.split(" ").count());
376 make_test!(split_ad_str, s, s.split("ad").count());
963 ($($fname:ident, $type:ty, $count:expr, $init:expr);*) => {
968 let src: Vec<$type> = black_box(vec![$init; $count]);
1608 b.iter(|| src.clone().drain_filter(|_, _| true).count())
1616 assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2);
1624 b.iter(|| src.clone().into_iter().count())
1679 b.iter(|| src.clone().drain_filter(|_, _| true).count())
1687 assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 10_000 / 2);
1695 b.iter(|| src.clone().into_iter().count())
1750 b.iter(|| src.clone().drain_filter(|_, _| true).count())
1758 assert_eq!(map.drain_filter(|i, _| i % 2 == 0).count(), 100 / 2);
1766 b.iter(|| src.clone().into_iter().count())
1876 b.iter(|| src.clone().drain_filter(|_| true).count())
1884 assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 100 / 2);
1892 b.iter(|| src.clone().into_iter().count())
1947 b.iter(|| src.clone().drain_filter(|_| true).count())
1955 assert_eq!(set.drain_filter(|i| i % 2 == 0).count(), 10_000 / 2);
1963 b.iter(|| src.clone().into_iter().count())
2003 set_bench! {intersection_100_neg_vs_100_pos, intersection, count, [neg(100), pos(100)]}
2004 set_bench! {intersection_100_neg_vs_10k_pos, intersection, count, [neg(100), pos(10_000)]}
2005 set_bench! {intersection_100_pos_vs_100_neg, intersection, count, [pos(100), neg(100)]}
2006 set_bench! {intersection_100_pos_vs_10k_neg, intersection, count, [pos(100), neg(10_000)]}
2007 set_bench! {intersection_10k_neg_vs_100_pos, intersection, count, [neg(10_000), pos(100)]}
2008 set_bench! {intersection_10k_neg_vs_10k_pos, intersection, count, [neg(10_000), pos(10_000)]}
2009 set_bench! {intersection_10k_pos_vs_100_neg, intersection, count, [pos(10_000), neg(100)]}
2010 set_bench! {intersection_10k_pos_vs_10k_neg, intersection, count, [pos(10_000), neg(10_000)]}
2011 set_bench! {intersection_random_100_vs_100, intersection, count, [random(100), random(100)]}
2012 set_bench! {intersection_random_100_vs_10k, intersection, count, [random(100), random(10_000)]}
2013 set_bench! {intersection_random_10k_vs_100, intersection, count, [random(10_000), random(100)]}
2014 set_bench! {intersection_random_10k_vs_10k, intersection, count, [random(10_000), random(10_000)]}
2015 set_bench! {intersection_staggered_100_vs_100, intersection, count, stagger(100, 1)}
2016 set_bench! {intersection_staggered_10k_vs_10k, intersection, count, stagger(10_000, 1)}
2017 set_bench! {intersection_staggered_100_vs_10k, intersection, count, stagger(100, 100)}
2018 set_bench! {difference_random_100_vs_100, difference, count, [random(100), random(100)]}
2019 set_bench! {difference_random_100_vs_10k, difference, count, [random(100), random(10_000)]}
2020 set_bench! {difference_random_10k_vs_100, difference, count, [random(10_000), random(100)]}
2021 set_bench! {difference_random_10k_vs_10k, difference, count, [random(10_000), random(10_000)]}
2022 set_bench! {difference_staggered_100_vs_100, difference, count, stagger(100, 1)}
2023 set_bench! {difference_staggered_10k_vs_10k, difference, count, stagger(10_000, 1)}
2024 set_bench! {difference_staggered_100_vs_10k, difference, count, stagger(100, 100)}
2294 let mut count = 0;
2296 count += 1;
2297 if count % 1_000_000_000 == 0 {
2302 black_box(count);
2971 let mut count = 0;
2977 count += 1;
2978 assert_eq!(iter.size_hint(), (0, Some(initial_len - count)));
2985 assert_eq!(count, initial_len);
2995 let mut count = 0;
3001 count += 1;
3008 assert_eq!(count, 0);
3018 let mut count = 0;
3024 count += 1;
3025 assert_eq!(iter.size_hint(), (0, Some(initial_len - count)));
3032 assert_eq!(count, initial_len);
4084 iter.by_ref().count(); // exhaust it
4092 iter.by_ref().count(); // exhaust it
4603 assert_eq!(s.chars().count(), v.len());
4720 assert_eq!(b.count(), 28)
5576 assert_eq!(s.chars().count(), 4);
6030 let mut count = 0;
6032 count += 1;
6033 match count {
6319 // Check isize::MAX doesn't count as an overflow
6329 // Check isize::MAX + 1 does count as overflow
6335 // Check usize::MAX does count as overflow
6543 count: &'a mut u32,
6548 *self.count += 1;
6567 tv.x.push(DropCounter { count: &mut count_x });
6568 tv.y.push(DropCounter { count: &mut count_y });
6684 let y = vec![DropCounter { count: &mut count_x }];
6957 assert_eq!(v.iter().count(), 0);
6959 assert_eq!(v.iter().count(), 1);
6961 assert_eq!(v.iter().count(), 2);
6965 assert_eq!(v.iter_mut().count(), 2);
6967 assert_eq!(v.iter_mut().count(), 3);
6969 assert_eq!(v.iter_mut().count(), 4);
6975 assert_eq!(v.iter_mut().count(), 0);
7455 assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
7577 drop_count.iter().map(Rc::strong_count).all(|count| count == 1),
7706 let mut count = 0;
7711 count += 1;
7712 assert_eq!(iter.size_hint(), (0, Some(initial_len - count)));
7719 assert_eq!(count, initial_len);
7729 let mut count = 0;
7734 count += 1;
7741 assert_eq!(count, 0);
7751 let mut count = 0;
7756 count += 1;
7757 assert_eq!(iter.size_hint(), (0, Some(initial_len - count)));
7764 assert_eq!(count, initial_len);
7885 for (index, count) in drop_counts.iter().cloned().enumerate() {
7886 assert_eq!(1, count, "unexpected drop count at index: {} (count: {})", index, count);
7936 for (index, count) in drop_counts.iter().cloned().enumerate() {
7937 assert_eq!(1, count, "unexpected drop count at index: {} (count: {})", index, count);
7998 // Check isize::MAX doesn't count as an overflow
8008 // Check isize::MAX + 1 does count as overflow
8014 // Check usize::MAX does count as overflow
8579 assert_eq!(tester.iter().count(), len);
8829 let count = core::sync::atomic::AtomicU32::new(0);
8831 Panic { drop_count: &count, aaaaa: false },
8832 Panic { drop_count: &count, aaaaa: true },
8833 Panic { drop_count: &count, aaaaa: false },
8843 assert_eq!(count.load(Ordering::SeqCst), 4);
9739 // This comparison includes the count (the second item
10532 assert_eq!(xs.split_mut(|x| *x == 0).count(), 6);
10734 count: Arc<AtomicUsize>,
10740 self.count.fetch_add(1, Ordering::SeqCst);
10750 Canary { count: self.count.clone(), panics: self.panics }
10755 let canary = Canary { count: drop_count.clone(), panics: false };
10756 let panic = Canary { count: drop_count.clone(), panics: true };
10925 let mut count = 0usize;
10927 count += 1;
10932 for panic_countdown in 0..count {
10956 let count = c.load(Relaxed);
10957 assert!(count == 1, "found drop count == {} for i == {}, len == {}", count, i, len);
12229 count: &'a mut u32,
12234 *self.count += 1;
12244 a.push_back(DropCounter { count: &mut count_a });
12245 b.push_back(DropCounter { count: &mut count_b });
12377 // Check isize::MAX doesn't count as an overflow
12387 // Check isize::MAX + 1 does count as overflow
12393 // Check usize::MAX does count as overflow
12948 assert_eq!(tester.iter().count(), len);
13560 assert_eq!(q.drain().take(5).count(), 5);
13712 // update global drop count
15256 /// replaces them with the replacement string slice at most `count` times.
15278 pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) -> String {
15282 for (start, part) in self.match_indices(pat).take(count) {
15954 let count = if cfg!(miri) { 1000 } else { 1000000 };
15955 for _i in 0..count {
15963 assert!(n < 2, "bad weak count: {}", n);
17625 /// assert_eq!(fancy_f.chars().count(), 3);
19610 //! // the reference count in the process.
19722 //! // gadgets, so they are destroyed. This zeroes the reference count on
19890 // updates to the weak reference count which might not be necessary
20097 // the strong count, and then remove the implicit "strong weak"
20408 /// Increments the strong reference count on the `Rc<T>` associated with the
20414 /// associated `Rc` instance must be valid (i.e. the strong count must be at
20441 /// Decrements the strong reference count on the `Rc<T>` associated with the
20447 /// associated `Rc` instance must be valid (i.e. the strong count must be at
20542 // We are careful to *not* create a reference covering the "count" fields, as
20648 // reference count is guaranteed to be 1 at this point, and we required
20885 /// This will decrement the strong reference count. If the strong reference
20886 /// count reaches zero then the only other references (if any) are
20932 /// strong reference count.
21426 /// Since a `Weak` reference does not count towards ownership, it will not
21541 /// one weak reference (the weak count is not modified by this operation). It can be turned
21575 /// later) or to deallocate the weak count by dropping the `Weak<T>`.
21585 /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
21587 /// count is not modified by this operation) and therefore it must be paired with a previous
21607 /// // Decrement the last weak count.
21787 // the weak count starts at 1, and will only go to zero if all
21848 // if you mem::forget Rcs (or Weaks), the ref-count can overflow, and then
21871 // The reference count will never be zero when this is called;
21895 // The reference count will never be zero when this is called;
23240 // Increment the reference count of the arc to clone it.
23261 // Decrement the reference count of the Arc on drop
23336 /// source `Arc`, while increasing a reference count. When the last `Arc`
23365 /// [`RefCell<T>`] is not thread safe; it keeps track of the borrowing count using
23525 /// Since a `Weak` reference does not count towards ownership, it will not
23600 // Start the weak pointer count as 1 which is the weak pointer that's
23649 // updates to the weak reference count which might not be necessary
23660 // observe a non-zero strong count. Therefore we need at least "Release" ordering
23666 // - It can *clone* the `Weak`, increasing the weak reference count.
23667 // - It can drop those clones, decreasing the weak reference count (but never to zero).
23767 // Start the weak pointer count as 1 which is the weak pointer that's
24173 /// Another thread can change the weak count at any time,
24192 // If the weak count is currently locked, the value of the
24193 // count was 0 just before taking the lock.
24202 /// Another thread can change the strong count at any time,
24223 /// Increments the strong reference count on the `Arc<T>` associated with the
24229 /// associated `Arc` instance must be valid (i.e. the strong count must be at
24258 /// Decrements the strong reference count on the `Arc<T>` associated with the
24264 /// associated `Arc` instance must be valid (i.e. the strong count must be at
24525 /// strong reference count.
24552 // is `mem::forget`ing Arcs. If we don't do this the count can overflow
24555 // the reference count at once. This branch will never be taken in
24623 // weak count, there's no chance the ArcInner itself could be
24644 // usize::MAX (i.e., locked), since the weak count can only be
24660 // strong ref count.
24701 // reference count is guaranteed to be 1 at this point, and we required
24740 // We are careful to *not* create a reference covering the "count" fields, as
24748 /// Note that this requires locking the weak ref count.
24750 // lock the weak pointer count if we appear to be the sole weak pointer
24755 // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
24778 /// This will decrement the strong reference count. If the strong reference
24779 /// count reaches zero then the only other references (if any) are
24805 // same logic applies to the below `fetch_sub` to the `weak` count.
24812 // of the reference count synchronizes with this `Acquire` fence. This
24814 // count, which happens before this fence, which happens before the
24953 /// one weak reference (the weak count is not modified by this operation). It can be turned
24987 /// later) or to deallocate the weak count by dropping the `Weak<T>`.
24997 /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
24999 /// count is not modified by this operation) and therefore it must be paired with a previous
25018 /// // Decrement the last weak count.
25073 // We use a CAS loop to increment the strong count instead of a
25074 // fetch_add as this function should never take the reference count
25134 // after reading the weak count, we know that the implicit weak
25136 // was still around when we observed the weak count, and can
25230 // fetch_add (ignoring the lock) because the weak count is only locked
25297 // weak count can only be locked if there was precisely one weak ref,
26097 //! width := count
26098 //! precision := count | '*'
26100 //! count := parameter | integer
29409 count: usize,
29418 DeterministicRng { count: 0, x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb }
29423 self.count += 1;
29424 assert!(self.count <= 70029);
30898 /// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
30900 /// // count the number of occurrences of letters in the vec
30902 /// *count.entry(x).or_insert(0) += 1;
30905 /// assert_eq!(count["a"], 3);
35213 /// map.entry("poneyland").or_insert_with_key(|key| key.chars().count());
35626 assert_eq!(self.length, self.keys().count());
35817 assert_eq!(map.keys().count(), 0);
35818 assert_eq!(map.values().count(), 0);
35881 assert_eq!(map.keys().count(), 0);
35882 assert_eq!(map.values().count(), 0);
35949 assert_eq!(map.iter_mut().count(), size);
35950 assert_eq!(map.iter_mut().rev().count(), size);
36625 assert_eq!(map.drain_filter(|i, _| *i % 2 == 0).count(), 8);
36922 assert_eq!(m.iter().count(), 1);
36932 assert_eq!(m.iter().count(), 1);
39265 pub fn bulk_steal_left(&mut self, count: usize) {
39266 assert!(count > 0);
39274 assert!(old_right_len + count <= CAPACITY);
39275 assert!(old_left_len >= count);
39277 let new_left_len = old_left_len - count;
39278 let new_right_len = old_right_len + count;
39285 slice_shr(right_node.key_area_mut(..new_right_len), count);
39286 slice_shr(right_node.val_area_mut(..new_right_len), count);
39291 right_node.key_area_mut(..count - 1),
39295 right_node.val_area_mut(..count - 1),
39304 right_node.key_area_mut(count - 1).write(k);
39305 right_node.val_area_mut(count - 1).write(v);
39311 slice_shr(right.edge_area_mut(..new_right_len + 1), count);
39316 right.edge_area_mut(..count),
39328 pub fn bulk_steal_right(&mut self, count: usize) {
39329 assert!(count > 0);
39337 assert!(old_left_len + count <= CAPACITY);
39338 assert!(old_right_len >= count);
39340 let new_left_len = old_left_len + count;
39341 let new_right_len = old_right_len - count;
39348 let k = right_node.key_area_mut(count - 1).assume_init_read();
39349 let v = right_node.val_area_mut(count - 1).assume_init_read();
39358 right_node.key_area_mut(..count - 1),
39362 right_node.val_area_mut(..count - 1),
39367 slice_shl(right_node.key_area_mut(..old_right_len), count);
39368 slice_shl(right_node.val_area_mut(..old_right_len), count);
39375 right.edge_area_mut(..count),
39380 slice_shl(right.edge_area_mut(..old_right_len + 1), count);
39874 let count = (MIN_LEN + 1).saturating_sub(left_len);
39875 if count > 0 {
39876 internal_kv.bulk_steal_right(count);
39894 let count = (MIN_LEN + 1).saturating_sub(right_len);
39895 if count > 0 {
39896 internal_kv.bulk_steal_left(count);
40115 use super::{count, Iter, VecDeque};
40168 let tail_len = count(orig_tail, drain_tail, source_deque.cap());
40169 let head_len = count(drain_head, orig_head, source_deque.cap());
41399 count(self.tail, self.head, self.cap())
42997 fn count(tail: usize, head: usize, size: usize) -> usize {
43285 use super::{count, wrap_index, RingSlices};
43332 let len = count(self.tail, self.head, self.ring.len());
43371 if n >= count(self.tail, self.head, self.ring.len()) {
44122 use super::{count, wrap_index, RingSlices};
44177 let len = count(self.tail, self.head, self.ring.len());
44194 if n >= count(self.tail, self.head, self.ring.len()) {
46007 fn count(self) -> usize {
48503 let count = unsafe { (*other).len() };
48504 self.reserve(count);
48506 unsafe { ptr::copy_nonoverlapping(other as *const T, self.as_mut_ptr().add(len), count) };
48507 self.len += count;
49096 let count = src.len();
49109 // - `count` is equal to the len of `source`, so source is valid for
49110 // `count` reads
49111 // - `.reserve(count)` guarantees that `spare.len() >= count` so spare
49112 // is valid for `count` writes
49113 unsafe { ptr::copy_nonoverlapping(source.as_ptr(), spare.as_mut_ptr() as _, count) };
49118 self.len += count;
50036 // Now we have an exact count.