Returns the number of elements in the specified iterator that equal the specified object. The iterator will be left exhausted: its hasNext() method will return false. @see Collections#frequency
(Iterator<?> iterator, @Nullable Object element)
| 396 | |
| 397 | |
| 398 | public static int frequency(Iterator<?> iterator, @Nullable Object element) { |
| 399 | return size(filter(iterator, equalTo(element))); |
| 400 | } |
| 401 | |
| 402 | /** |
| 403 | * Returns an iterator that cycles indefinitely over the elements of {@code |