UnorderedFoldableOps

final class UnorderedFoldableOps[F[_], A](fa: F[A]) extends AnyVal
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def count(p: A => Boolean)(F: UnorderedFoldable[F]): Long

Count the number of elements in the structure that satisfy the given predicate.

Count the number of elements in the structure that satisfy the given predicate.

For example:

scala> import cats.implicits._
scala> val map1 = Map[Int, String]()
scala> val p1: String => Boolean = _.length > 0
scala> map1.count(p1)
res0: Long = 0

scala> val map2 = Map(1 -> "hello", 2 -> "world", 3 -> "!")
scala> val p2: String => Boolean = _.length > 1
scala> map2.count(p2)
res1: Long = 2