NonEmptyChainOps

cats.data.NonEmptyChainOps
final class NonEmptyChainOps[A](value: Type[A]) extends AnyVal

Attributes

Source
NonEmptyChain.scala
Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Value members

Concrete methods

final def ++[A2 >: A](c: Type[A2]): Type[A2]

Alias for concat

Alias for concat

Attributes

Source
NonEmptyChain.scala
final def ++:[A2 >: A](c: Chain[A2]): Type[A2]

Alias for prependChain

Alias for prependChain

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(4, 5, 6)
scala> Chain(1, 2, 3) ++: nec
res0: cats.data.NonEmptyChain[Int] = Chain(1, 2, 3, 4, 5, 6)

Attributes

Source
NonEmptyChain.scala
final def +:[A2 >: A](a: A2): Type[A2]

Alias for prepend.

Alias for prepend.

Attributes

Source
NonEmptyChain.scala
final def :+[A2 >: A](a: A2): Type[A2]

Alias for append.

Alias for append.

Attributes

Source
NonEmptyChain.scala
final def :++[A2 >: A](c: Chain[A2]): Type[A2]

Alias for appendChain

Alias for appendChain

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(1, 2, 4, 5)
scala> nec :++ Chain(3, 6, 9)
res0: cats.data.NonEmptyChain[Int] = Chain(1, 2, 4, 5, 3, 6, 9)

Attributes

Source
NonEmptyChain.scala
final def append[A2 >: A](a: A2): Type[A2]

Returns a new Chain consisting of this followed by a.

Returns a new Chain consisting of this followed by a. O(1) runtime.

Attributes

Source
NonEmptyChain.scala
final def appendChain[A2 >: A](c: Chain[A2]): Type[A2]

Appends the given chain in O(1) runtime.

Appends the given chain in O(1) runtime.

Attributes

Source
NonEmptyChain.scala
final def collect[B](pf: PartialFunction[A, B]): Chain[B]

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

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

scala> import cats.data.NonEmptyChain
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(4, 5, 6).map(n => if (n % 2 == 0) Some(n) else None)
scala> nec.collect { case Some(n) => n }
res0: cats.data.Chain[Int] = Chain(4, 6)

Attributes

Source
NonEmptyChain.scala
final def collectFirst[B](pf: PartialFunction[A, B]): Option[B]

Finds the first element of this NonEmptyChain for which the given partial function is defined, and applies the partial function to it.

Finds the first element of this NonEmptyChain for which the given partial function is defined, and applies the partial function to it.

Attributes

Source
NonEmptyChain.scala
final def collectFirstSome[B](f: A => Option[B]): Option[B]

Like collectFirst from scala.collection.Traversable but takes A => Option[B] instead of PartialFunctions.

Like collectFirst from scala.collection.Traversable but takes A => Option[B] instead of PartialFunctions.

Attributes

Source
NonEmptyChain.scala
final def concat[A2 >: A](c: Type[A2]): Type[A2]

Concatenates this with c in O(1) runtime.

Concatenates this with c in O(1) runtime.

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(1, 2, 4, 5)
scala> nec ++ NonEmptyChain(7, 8)
res0: cats.data.NonEmptyChain[Int] = Chain(1, 2, 4, 5, 7, 8)

Attributes

Source
NonEmptyChain.scala
final def contains(a: A)(implicit A: Eq[A]): Boolean

Tests if some element is contained in this chain.

Tests if some element is contained in this chain.

scala> import cats.data.NonEmptyChain
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(4, 5, 6)
scala> nec.contains(5)
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def deleteFirst(f: A => Boolean): Option[(A, Chain[A])]

Yields to Some(a, Chain[A]) with a removed where f holds for the first time, otherwise yields None, if a was not found Traverses only until a is found.

Yields to Some(a, Chain[A]) with a removed where f holds for the first time, otherwise yields None, if a was not found Traverses only until a is found.

Attributes

Source
NonEmptyChain.scala
final def distinct[AA >: A](implicit O: Order[AA]): Type[AA]

Remove duplicates.

Remove duplicates. Duplicates are checked using Order[_] instance.

Attributes

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

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

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

Attributes

Source
NonEmptyChain.scala
final def filter(p: A => Boolean): Chain[A]

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

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

Attributes

Source
NonEmptyChain.scala
final def filterNot(p: A => Boolean): Chain[A]

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

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

Attributes

Source
NonEmptyChain.scala
final 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
NonEmptyChain.scala
final def flatMap[B](f: A => Type[B]): Type[B]

Applies the supplied function to each element and returns a new NonEmptyChain from the concatenated results

Applies the supplied function to each element and returns a new NonEmptyChain from the concatenated results

Attributes

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

Left-associative fold using f.

Left-associative fold using f.

Attributes

Source
NonEmptyChain.scala
final def foldRight[B](z: B)(f: (A, B) => B): B

Right-associative fold using f.

Right-associative fold using f.

Attributes

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

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

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

Attributes

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

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

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

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(12, -2, 3, -5)
scala> val expectedResult = NonEmptyMap.of(false -> NonEmptyChain(-2, -5), true -> NonEmptyChain(12, 3))
scala> val result = nec.groupBy(_ >= 0)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupByNem[B](f: A => B)(implicit B: Order[B]): Type[B, Type[A]]

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

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

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(12, -2, 3, -5)
scala> val expectedResult = NonEmptyMap.of(false -> NonEmptyChain(-2, -5), true -> NonEmptyChain(12, 3))
scala> val result = nec.groupByNem(_ >= 0)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMap[K, B](key: A => K)(f: A => B)(implicit K: Order[K]): Type[K, Type[B]]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. And each element in a group is transformed into a value of type B using the mapping function.

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(12, -2, 3, -5)
scala> val expectedResult = NonEmptyMap.of(false -> NonEmptyChain("-2", "-5"), true -> NonEmptyChain("12", "3"))
scala> val result = nec.groupMap(_ >= 0)(_.toString)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMapNem[K, B](key: A => K)(f: A => B)(implicit K: Order[K]): Type[K, Type[B]]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. And each element in a group is transformed into a value of type B using the mapping function.

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain(12, -2, 3, -5)
scala> val expectedResult = NonEmptyMap.of(false -> NonEmptyChain("-2", "-5"), true -> NonEmptyChain("12", "3"))
scala> val result = nec.groupMapNem(_ >= 0)(_.toString)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMapReduce[K, B](key: A => K)(f: A => B)(implicit K: Order[K], B: Semigroup[B]): Type[K, B]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. Then each element in a group is transformed into a value of type B using the mapping function. And finally they are all reduced into a single value using their Semigroup

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain("Hello", "World", "Goodbye", "World")
scala> val expectedResult = NonEmptyMap.of("goodbye" -> 1, "hello" -> 1, "world" -> 2)
scala> val result = nec.groupMapReduce(_.trim.toLowerCase)(_ => 1)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMapReduceNem[K, B](key: A => K)(f: A => B)(implicit K: Order[K], B: Semigroup[B]): Type[K, B]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. Then each element in a group is transformed into a value of type B using the mapping function. And finally they are all reduced into a single value using their Semigroup

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain("Hello", "World", "Goodbye", "World")
scala> val expectedResult = NonEmptyMap.of("goodbye" -> 1, "hello" -> 1, "world" -> 2)
scala> val result = nec.groupMapReduceNem(_.trim.toLowerCase)(_ => 1)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMapReduceWith[K, B](key: A => K)(f: A => B)(combine: (B, B) => B)(implicit K: Order[K]): Type[K, B]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. Then each element in a group is transformed into a value of type B using the mapping function. And finally they are all reduced into a single value using the provided combine function.

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain("Hello", "World", "Goodbye", "World")
scala> val expectedResult = NonEmptyMap.of("goodbye" -> 1, "hello" -> 1, "world" -> 2)
scala> val result = nec.groupMapReduceWith(_.trim.toLowerCase)(_ => 1)(_ + _)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def groupMapReduceWithNem[K, B](key: A => K)(f: A => B)(combine: (B, B) => B)(implicit K: Order[K]): Type[K, B]

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function.

Groups elements inside this NonEmptyChain according to the Order of the keys produced by the given key function. Then each element in a group is transformed into a value of type B using the mapping function. And finally they are all reduced into a single value using the provided combine function.

scala> import cats.data.{NonEmptyChain, NonEmptyMap}
scala> import cats.syntax.all._
scala> val nec = NonEmptyChain("Hello", "World", "Goodbye", "World")
scala> val expectedResult = NonEmptyMap.of("goodbye" -> 1, "hello" -> 1, "world" -> 2)
scala> val result = nec.groupMapReduceWithNem(_.trim.toLowerCase)(_ => 1)(_ + _)
scala> result === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def grouped(size: Int): Iterator[Type[A]]

Partitions elements in fixed size NonEmptyChains.

Partitions elements in fixed size NonEmptyChains.

scala> import cats.data.NonEmptyChain
scala> import cats.syntax.all._
scala> val nel = NonEmptyChain.of(12, -2, 3, -5)
scala> val expectedResult = List(NonEmptyChain.of(12, -2), NonEmptyChain.of(3, -5))
scala> val result = nel.grouped(2)
scala> result.toList === expectedResult
res0: Boolean = true

Attributes

Source
NonEmptyChain.scala
final def head: A

Returns the first element of this NonEmptyChain.

Returns the first element of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def init: Chain[A]

Returns all but the last element of this NonEmptyChain.

Returns all but the last element of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def initLast: (Chain[A], A)

Returns the init and last of this NonEmptyChain.

Returns the init and last of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def iterator: Iterator[A]

Attributes

Source
NonEmptyChain.scala
final def last: A

Returns the last element of this NonEmptyChain.

Returns the last element of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def length: Long

Returns the number of elements in this chain.

Returns the number of elements in this chain.

Attributes

Source
NonEmptyChain.scala
final def map[B](f: A => B): Type[B]

Applies the supplied function to each element and returns a new NonEmptyChain.

Applies the supplied function to each element and returns a new NonEmptyChain.

Attributes

Source
NonEmptyChain.scala
final def prepend[A2 >: A](a: A2): Type[A2]

Returns a new NonEmptyChain consisting of a followed by this.

Returns a new NonEmptyChain consisting of a followed by this. O(1) runtime.

Attributes

Source
NonEmptyChain.scala
final def prependChain[A2 >: A](c: Chain[A2]): Type[A2]

Prepends the given chain in O(1) runtime.

Prepends the given chain in O(1) runtime.

Attributes

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

Reduce using the Semigroup of A

Reduce using the Semigroup of A

Attributes

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

Left-associative reduce using f.

Left-associative reduce using f.

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(4, 5, 6)
scala> nec.reduceLeft(_ + _)
res0: Int = 15

Attributes

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

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

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

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(4, 5, 6)
scala> nec.reduceLeftTo(_.toString)((acc, cur) => acc + cur.toString)
res0: String = 456

Attributes

Source
NonEmptyChain.scala
final def reduceRight(f: (A, A) => A): A

Right-associative reduce using f.

Right-associative reduce using f.

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(4, 5, 6)
scala> nec.reduceRight(_ + _)
res0: Int = 15

Attributes

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

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

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

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(4, 5, 6)
scala> nec.reduceRightTo(_.toString)((cur, acc) => acc + cur.toString)
res0: String = 654

Attributes

Source
NonEmptyChain.scala
final def reverse: Type[A]

Reverses this NonEmptyChain

Reverses this NonEmptyChain

Attributes

Source
NonEmptyChain.scala
final def reverseIterator: Iterator[A]

Attributes

Source
NonEmptyChain.scala
final def show[AA >: A](implicit AA: Show[AA]): String

Attributes

Source
NonEmptyChain.scala
final def sortBy[B](f: A => B)(implicit B: Order[B]): Type[A]

Attributes

Source
NonEmptyChain.scala
final def sorted[AA >: A](implicit AA: Order[AA]): Type[AA]

Attributes

Source
NonEmptyChain.scala
final def tail: Chain[A]

Returns all but the first element of this NonEmptyChain.

Returns all but the first element of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def toChain: Chain[A]

Converts this chain to a Chain

Converts this chain to a Chain

Attributes

Source
NonEmptyChain.scala
final def toNem[T, V](implicit ev: A <:< (T, V), order: Order[T]): Type[T, V]

Attributes

Source
NonEmptyChain.scala
final def toNes[B >: A](implicit order: Order[B]): Type[B]

Attributes

Source
NonEmptyChain.scala

Converts this chain to a NonEmptyList.

Converts this chain to a NonEmptyList.

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(1, 2, 3, 4, 5)
scala> nec.toNonEmptyList
res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5)

Attributes

Source
NonEmptyChain.scala

Converts this chain to a NonEmptyVector.

Converts this chain to a NonEmptyVector.

scala> import cats.data.NonEmptyChain
scala> val nec = NonEmptyChain(1, 2, 3, 4, 5)
scala> nec.toNonEmptyVector
res0: cats.data.NonEmptyVector[Int] = NonEmptyVector(1, 2, 3, 4, 5)

Attributes

Source
NonEmptyChain.scala
final def uncons: (A, Chain[A])

Returns the head and tail of this NonEmptyChain.

Returns the head and tail of this NonEmptyChain. Amortized O(1).

Attributes

Source
NonEmptyChain.scala
final def zipWith[B, C](b: Type[B])(f: (A, B) => C): Type[C]

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

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

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

Attributes

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

Attributes

Source
NonEmptyChain.scala