NonEmptySetOps

cats.data.NonEmptySetOps
sealed class NonEmptySetOps[A](val value: Type[A])

Attributes

Source
NonEmptySet.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def &(as: Type[A]): SortedSet[A]

Alias for intersect

Alias for intersect

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 4, 5)
scala> nes & NonEmptySet.of(1, 2, 7)
res0: scala.collection.immutable.SortedSet[Int] = TreeSet(1, 2)

Attributes

Source
NonEmptySet.scala
def &~(as: Type[A]): SortedSet[A]

Alias for diff

Alias for diff

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 4, 5)
scala> nes &~ NonEmptySet.of(1, 2, 7)
res0: scala.collection.immutable.SortedSet[Int] = TreeSet(4, 5)

Attributes

Source
NonEmptySet.scala
def ++(as: Type[A]): Type[A]

Alias for union

Alias for union

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 4, 5)
scala> nes ++ NonEmptySet.of(1, 2, 7)
res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 4, 5, 7)

Attributes

Source
NonEmptySet.scala
def -(a: A): SortedSet[A]

Removes a key from this set, returning a new SortedSet.

Removes a key from this set, returning a new SortedSet.

Attributes

Source
NonEmptySet.scala
def --(as: Type[A]): SortedSet[A]

Alias for diff

Alias for diff

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 4, 5)
scala> nes -- NonEmptySet.of(1, 2, 7)
res0: scala.collection.immutable.SortedSet[Int] = TreeSet(4, 5)

Attributes

Source
NonEmptySet.scala
def ===(that: Type[A]): Boolean

Typesafe equality operator.

Typesafe equality operator.

This method is similar to == except that it only allows two NonEmptySet[A] values to be compared to each other, and uses equality provided by Eq[_] instances, rather than using the universal equality provided by .equals.

Attributes

Source
NonEmptySet.scala
def add(a: A): Type[A]

Adds an element to this set, returning a new NonEmptySet

Adds an element to this set, returning a new NonEmptySet

Attributes

Source
NonEmptySet.scala
def apply(a: A): Boolean

Alias for contains

Alias for contains

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 3, 4, 5)
scala> nes(3)
res0: Boolean = true
scala> nes(7)
res1: Boolean = false

Attributes

Source
NonEmptySet.scala
def collect[B](pf: PartialFunction[A, B])(implicit B: Order[B]): SortedSet[B]

Returns a new SortedSet containing all elements where the result of pf is defined.

Returns a new SortedSet containing all elements where the result of pf is defined.

Attributes

Source
NonEmptySet.scala
def concatMap[B](f: A => Type[B])(implicit B: Order[B]): Type[B]

Map a function over all the elements of this set and concatenate the resulting sets into one.

Map a function over all the elements of this set and concatenate the resulting sets into one.

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 3)
scala> nes.concatMap(n => NonEmptySet.of(n, n * 4, n * 5))
res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 3, 4, 5, 8, 10, 12, 15)

Attributes

Source
NonEmptySet.scala
def contains(a: A): Boolean

Tests if some element is contained in this set.

Tests if some element is contained in this set.

Attributes

Source
NonEmptySet.scala
def diff(as: Type[A]): SortedSet[A]

Computes the difference of this set and another set.

Computes the difference of this set and another set.

Attributes

Source
NonEmptySet.scala
def exists(f: A => Boolean): Boolean

Tests whether a predicate holds for at least one element of this set.

Tests whether a predicate holds for at least one element of this set.

Attributes

Source
NonEmptySet.scala
def filter(p: A => Boolean): SortedSet[A]

Filters all elements of this set that do not satisfy the given predicate.

Filters all elements of this set that do not satisfy the given predicate.

Attributes

Source
NonEmptySet.scala
def filterNot(p: A => Boolean): SortedSet[A]

Filters all elements of this set that satisfy the given predicate.

Filters all elements of this set that satisfy the given predicate.

Attributes

Source
NonEmptySet.scala
def find(f: A => Boolean): Option[A]

Returns the first value that matches the given predicate.

Returns the first value that matches the given predicate.

Attributes

Source
NonEmptySet.scala
def foldLeft[B](b: B)(f: (B, A) => B): B

Left-associative fold using f.

Left-associative fold using f.

Attributes

Source
NonEmptySet.scala
def foldRight[B](lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B]

Right-associative fold using f.

Right-associative fold using f.

Attributes

Source
NonEmptySet.scala
def forall(p: A => Boolean): Boolean

Tests whether a predicate holds for all elements of this set.

Tests whether a predicate holds for all elements of this set.

Attributes

Source
NonEmptySet.scala
def groupBy[B](f: A => B)(implicit B: Order[B]): Type[B, Type[A]]

Groups elements inside this NonEmptySet according to the Order of the keys produced by the given mapping function.

Groups elements inside this NonEmptySet according to the Order of the keys produced by the given mapping function.

Attributes

Source
NonEmptySet.scala
def head: A

Returns the first element of this set.

Returns the first element of this set.

Attributes

Source
NonEmptySet.scala
def intersect(as: Type[A]): SortedSet[A]

Computes the intersection between this set and another set.

Computes the intersection between this set and another set.

Attributes

Source
NonEmptySet.scala
def last: A

Returns the last element of this set.

Returns the last element of this set.

Attributes

Source
NonEmptySet.scala
def length: Int

Returns the number of elements in this set.

Returns the number of elements in this set.

Attributes

Source
NonEmptySet.scala
def map[B](f: A => B)(implicit B: Order[B]): Type[B]

Applies f to all the elements

Applies f to all the elements

Attributes

Source
NonEmptySet.scala
def reduce[AA >: A](implicit S: Semigroup[AA]): AA

Reduce using the Semigroup of A

Reduce using the Semigroup of A

Attributes

Source
NonEmptySet.scala
def reduceLeft(f: (A, A) => A): A

Left-associative reduce using f.

Left-associative reduce using f.

Attributes

Source
NonEmptySet.scala
def reduceLeftTo[B](f: A => B)(g: (B, A) => B): B

Apply f to the "initial element" of this set and lazily combine it with every other value using the given function g.

Apply f to the "initial element" of this set and lazily combine it with every other value using the given function g.

Attributes

Source
NonEmptySet.scala
def reduceRight(f: (A, Eval[A]) => Eval[A]): Eval[A]

Left-associative reduce using f.

Left-associative reduce using f.

Attributes

Source
NonEmptySet.scala
def reduceRightTo[B](f: A => B)(g: (A, Eval[B]) => Eval[B]): Eval[B]

Apply f to the "initial element" of this set and lazily combine it with every other value using the given function g.

Apply f to the "initial element" of this set and lazily combine it with every other value using the given function g.

Attributes

Source
NonEmptySet.scala
def show(implicit A: Show[A]): String

Typesafe stringification method.

Typesafe stringification method.

This method is similar to .toString except that it stringifies values according to Show[_] instances, rather than using the universal .toString method.

Attributes

Source
NonEmptySet.scala
def tail: SortedSet[A]

Returns all but the first element of this set.

Returns all but the first element of this set.

Attributes

Source
NonEmptySet.scala

Converts this set to a NonEmptyList.

Converts this set to a NonEmptyList.

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 3, 4, 5)
scala> nes.toNonEmptyList
res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)

Attributes

Source
NonEmptySet.scala

Converts this set to a SortedSet

Converts this set to a SortedSet

Attributes

Source
NonEmptySet.scala
def union(as: Type[A]): Type[A]

Computes the union between this NES and another NES.

Computes the union between this NES and another NES.

Attributes

Source
NonEmptySet.scala
def zipWith[B, C](b: Type[B])(f: (A, B) => C)(implicit C: Order[C]): Type[C]

Zips this NonEmptySet with another NonEmptySet and applies a function for each pair of elements.

Zips this NonEmptySet with another NonEmptySet and applies a function for each pair of elements.

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val as = NonEmptySet.of(1, 2, 3)
scala> val bs = NonEmptySet.of("A", "B", "C")
scala> as.zipWith(bs)(_.toString + _)
res0: cats.data.NonEmptySet[String] = TreeSet(1A, 2B, 3C)

Attributes

Source
NonEmptySet.scala
def zipWithIndex: Type[(A, Int)]

Zips this NonEmptySet with its index.

Zips this NonEmptySet with its index.

Attributes

Source
NonEmptySet.scala
def |(as: Type[A]): Type[A]

Alias for union

Alias for union

scala> import cats.data.NonEmptySet
scala> import cats.syntax.all._
scala> val nes = NonEmptySet.of(1, 2, 4, 5)
scala> nes | NonEmptySet.of(1, 2, 7)
res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 4, 5, 7)

Attributes

Source
NonEmptySet.scala