def forall[I]()

in algebird-core/src/main/scala/com/twitter/algebird/Fold.scala [318:335]


  def forall[I](pred: I => Boolean): Fold[I, Boolean] =
    foldLeft(true)((b, i) => b && pred(i))

  /**
   * A Fold that returns "true" if any element of the sequence statisfies the predicate. Note this does not
   * short-circuit enumeration of the sequence.
   */
  def exists[I](pred: I => Boolean): Fold[I, Boolean] =
    foldLeft(false)((b, i) => b || pred(i))

  /**
   * A Fold that counts the number of elements satisfying the predicate.
   */
  def count[I](pred: I => Boolean): Fold[I, Long] =
    foldLeft(0L) {
      case (c, i) if pred(i) => c + 1L
      case (c, _)            => c
    }