UnorderedFoldable

cats.UnorderedFoldable
See theUnorderedFoldable companion object
trait UnorderedFoldable[F[_]] extends Serializable

UnorderedFoldable is like a Foldable for unordered containers.

Attributes

Companion
object
Source
UnorderedFoldable.scala
Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait Foldable[F]
trait Reducible[F]
class NonEmptyReducible[F, G]
trait NonEmptyTraverse[F]
trait Traverse[F]
Show all

Members list

Value members

Abstract methods

def unorderedFoldMap[A, B : CommutativeMonoid](fa: F[A])(f: A => B): B

Attributes

Source
UnorderedFoldable.scala

Concrete methods

def contains_[A](fa: F[A], v: A)(implicit ev: Eq[A]): Boolean

Tests if fa contains v using the Eq instance for A

Tests if fa contains v using the Eq instance for A

Attributes

Source
UnorderedFoldable.scala
def count[A](fa: F[A])(p: A => Boolean): 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.syntax.all._
scala> val map1 = Map[Int, String]()
scala> val p1: String => Boolean = _.length > 0
scala> UnorderedFoldable[Map[Int, *]].count(map1)(p1)
res0: Long = 0

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

Attributes

Source
UnorderedFoldable.scala
def exists[A](fa: F[A])(p: A => Boolean): Boolean

Check whether at least one element satisfies the predicate.

Check whether at least one element satisfies the predicate.

If there are no elements, the result is false.

Attributes

Source
UnorderedFoldable.scala
def forall[A](fa: F[A])(p: A => Boolean): Boolean

Check whether all elements satisfy the predicate.

Check whether all elements satisfy the predicate.

If there are no elements, the result is true.

Attributes

Source
UnorderedFoldable.scala
def isEmpty[A](fa: F[A]): Boolean

Returns true if there are no elements.

Returns true if there are no elements. Otherwise false.

Attributes

Source
UnorderedFoldable.scala
def nonEmpty[A](fa: F[A]): Boolean

Attributes

Source
UnorderedFoldable.scala
def size[A](fa: F[A]): Long

The size of this UnorderedFoldable.

The size of this UnorderedFoldable.

This is overridden in structures that have more efficient size implementations (e.g. Vector, Set, Map).

Note: will not terminate for infinite-sized collections.

Attributes

Source
UnorderedFoldable.scala

Attributes

Source
UnorderedFoldable.scala