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)
| 380 | * @see Collections#frequency |
| 381 | */ |
| 382 | public static int frequency(Iterator<?> iterator, @Nullable Object element) { |
| 383 | return size(filter(iterator, equalTo(element))); |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Returns an iterator that cycles indefinitely over the elements of {@code |