final class NonEmptyChainOps[A] extends AnyVal
- Alphabetic
- By Inheritance
- NonEmptyChainOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new NonEmptyChainOps(value: NonEmptyChain[A])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
final
def
++[A2 >: A](c: NonEmptyChain[A2]): NonEmptyChain[A2]
Alias for concat
-
final
def
++:[A2 >: A](c: Chain[A2]): NonEmptyChain[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)
-
final
def
+:[A2 >: A](a: A2): NonEmptyChain[A2]
Alias for prepend.
-
final
def
:+[A2 >: A](a: A2): NonEmptyChain[A2]
Alias for append.
-
final
def
:++[A2 >: A](c: Chain[A2]): NonEmptyChain[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)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
append[A2 >: A](a: A2): NonEmptyChain[A2]
Returns a new Chain consisting of this followed by
a
.Returns a new Chain consisting of this followed by
a
. O(1) runtime. -
final
def
appendChain[A2 >: A](c: Chain[A2]): NonEmptyChain[A2]
Appends the given chain in O(1) runtime.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
collect[B](pf: PartialFunction[A, B]): Chain[B]
Returns a new
Chain
containing all elements where the result ofpf
is final defined.Returns a new
Chain
containing all elements where the result ofpf
is final defined.scala> import cats.data.NonEmptyChain scala> import cats.implicits._ 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)
-
final
def
concat[A2 >: A](c: NonEmptyChain[A2]): NonEmptyChain[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)
-
final
def
contains(a: A)(implicit A: kernel.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.implicits._ scala> val nec = NonEmptyChain(4, 5, 6) scala> nec.contains(5) res0: Boolean = true
-
final
def
deleteFirst(f: (A) ⇒ Boolean): Option[(A, Chain[A])]
Yields to Some(a, Chain[A]) with
a
removed wheref
holds for the first time, otherwise yields None, ifa
was not found Traverses only untila
is found. -
final
def
distinct[AA >: A](implicit O: Order[AA]): NonEmptyChain[AA]
Remove duplicates.
Remove duplicates. Duplicates are checked using
Order[_]
instance. -
final
def
exists(f: (A) ⇒ Boolean): Boolean
Tests whether a predicate holds for at least one element of this chain.
-
final
def
filter(p: (A) ⇒ Boolean): Chain[A]
Filters all elements of this chain that do not satisfy the given predicate.
-
final
def
filterNot(p: (A) ⇒ Boolean): Chain[A]
Filters all elements of this chain that satisfy the given predicate.
-
final
def
find(f: (A) ⇒ Boolean): Option[A]
Returns the first value that matches the given predicate.
-
final
def
flatMap[B](f: (A) ⇒ NonEmptyChain[B]): NonEmptyChain[B]
Applies the supplied function to each element and returns a new NonEmptyChain from the concatenated results
-
final
def
foldLeft[B](b: B)(f: (B, A) ⇒ B): B
Left-associative fold using f.
-
final
def
foldRight[B](z: B)(f: (A, B) ⇒ B): B
Right-associative fold using f.
-
final
def
forall(p: (A) ⇒ Boolean): Boolean
Tests whether a predicate holds for all elements of this chain.
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
groupBy[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyMap[B, NonEmptyChain[A]]
Groups elements inside this
NonEmptyChain
according to theOrder
of the keys produced by the given mapping function. -
final
def
head: A
Returns the first element of this chain.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def iterator: Iterator[A]
-
final
def
length: Long
Returns the number of elements in this chain.
-
final
def
prepend[A2 >: A](a: A2): NonEmptyChain[A2]
Returns a new NonEmptyChain consisting of
a
followed by this.Returns a new NonEmptyChain consisting of
a
followed by this. O(1) runtime. -
final
def
prependChain[A2 >: A](c: Chain[A2]): NonEmptyChain[A2]
Prepends the given chain in O(1) runtime.
-
final
def
reduce[AA >: A](implicit S: kernel.Semigroup[AA]): AA
Reduce using the Semigroup of A
-
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
-
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 functiong
.Apply
f
to the "initial element" of this chain and lazily combine it with every other value using the given functiong
.scala> import cats.data.NonEmptyChain scala> val nec = NonEmptyChain(4, 5, 6) scala> nec.reduceLeftTo(_.toString)((acc, cur) => acc + cur.toString) res0: String = 456
-
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
-
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 functiong
.Apply
f
to the "initial element" of this chain and lazily combine it with every other value using the given functiong
.scala> import cats.data.NonEmptyChain scala> val nec = NonEmptyChain(4, 5, 6) scala> nec.reduceLeftTo(_.toString)((cur, acc) => acc + cur.toString) res0: String = 654
-
final
def
reverse: NonEmptyChain[A]
Reverses this
NonEmptyChain
- final def reverseIterator: Iterator[A]
-
final
def
tail: Chain[A]
Returns all but the first element of this chain.
-
final
def
toChain: Chain[A]
Converts this chain to a
Chain
-
final
def
toNonEmptyList: NonEmptyList[A]
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)
-
final
def
toNonEmptyVector: NonEmptyVector[A]
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)
-
def
toString(): String
- Definition Classes
- Any
-
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).
-
final
def
zipWith[B, C](b: NonEmptyChain[B])(f: (A, B) ⇒ C): NonEmptyChain[C]
Zips this
NonEmptyChain
with anotherNonEmptyChain
and applies a function for each pair of elements.Zips this
NonEmptyChain
with anotherNonEmptyChain
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)(_ + _) res0: cats.data.NonEmptyChain[String] = Chain(1A, 2B, 3C)