![]() |
VOOZH | about |
TreeSet class, the count() method is utilized to count the number of elements in the TreeSet that satisfies a given predicate.
Method Definition: def count(p: (A) => Boolean): Int Return Type: It returns the count the number of elements in the TreeSet that satisfies a given predicate.Example #1:
TreeSet(1, 2, 3, 4, 5) Number of even element in the TreeSet: 2
TreeSet(1, 2, 3, 4, 5) Number of odd element in the TreeSet: 3