final class NonEmptyVector[+A] extends AnyVal
A data type which represents a Vector
guaranteed to contain at least one element.
Note that the constructor is private
to prevent accidental construction of an empty
NonEmptyVector
. However, due to https://issues.scala-lang.org/browse/SI-6601, on
Scala 2.10, this may be bypassed due to a compiler bug.
- Alphabetic
- By Inheritance
- NonEmptyVector
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
def
++[AA >: A](other: Vector[AA]): NonEmptyVector[AA]
Alias for concat
-
def
++:[AA >: A](other: NonEmptyVector[AA]): NonEmptyVector[AA]
Append this NEV to another NEV, producing a new
NonEmptyVector
.Append this NEV to another NEV, producing a new
NonEmptyVector
.scala> import cats.data.NonEmptyVector scala> val nev = NonEmptyVector.of(1, 2, 3) scala> nev ++: NonEmptyVector.of(4, 5) res0: cats.data.NonEmptyVector[Int] = NonEmptyVector(1, 2, 3, 4, 5)
-
def
+:[AA >: A](a: AA): NonEmptyVector[AA]
Alias for prepend
-
def
:+[AA >: A](a: AA): NonEmptyVector[AA]
Alias for append
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
def
===[AA >: A](that: NonEmptyVector[AA])(implicit A: Eq[AA]): Boolean
Typesafe equality operator.
Typesafe equality operator.
This method is similar to == except that it only allows two NonEmptyVector[A] values to be compared to each other, and uses equality provided by Eq[_] instances, rather than using the universal equality provided by .equals.
-
def
append[AA >: A](a: AA): NonEmptyVector[AA]
Append an item to this, producing a new
NonEmptyVector
. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def collect[B](pf: PartialFunction[A, B]): Vector[B]
-
def
concat[AA >: A](other: Vector[AA]): NonEmptyVector[AA]
Append another
Vector
to this, producing a newNonEmptyVector
. -
def
concatNev[AA >: A](other: NonEmptyVector[AA]): NonEmptyVector[AA]
Append another
NonEmptyVector
to this, producing a newNonEmptyVector
. -
def
distinct[AA >: A](implicit O: Order[AA]): NonEmptyVector[AA]
Remove duplicates.
Remove duplicates. Duplicates are checked using
Order[_]
instance. -
def
exists(f: (A) ⇒ Boolean): Boolean
Check whether at least one element satisfies the predicate.
-
def
filter(f: (A) ⇒ Boolean): Vector[A]
Remove elements not matching the predicate
Remove elements not matching the predicate
scala> import cats.data.NonEmptyVector scala> val nev = NonEmptyVector.of(1, 2, 3, 4, 5) scala> nev.filter(_ < 3) res0: scala.collection.immutable.Vector[Int] = Vector(1, 2)
-
def
filterNot(f: (A) ⇒ Boolean): Vector[A]
Remove elements matching the predicate
Remove elements matching the predicate
scala> import cats.data.NonEmptyVector scala> val nev = NonEmptyVector.of(1, 2, 3, 4, 5) scala> nev.filterNot(_ < 3) res0: scala.collection.immutable.Vector[Int] = Vector(3, 4, 5)
-
def
find(f: (A) ⇒ Boolean): Option[A]
Find the first element matching the predicate, if one exists
-
def
flatMap[B](f: (A) ⇒ NonEmptyVector[B]): NonEmptyVector[B]
Applies f to all elements and combines the result
-
def
foldLeft[B](b: B)(f: (B, A) ⇒ B): B
Left-associative fold using f.
-
def
foldRight[B](lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]
Right-associative fold using f.
-
def
forall(f: (A) ⇒ Boolean): Boolean
Check whether all elements satisfy the predicate.
-
def
get(i: Int): Option[A]
Gets the element at the index, if it exists
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
def
getUnsafe(i: Int): A
Gets the element at the index, or throws an exception if none exists
- def head: A
- def init: Vector[A]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def last: A
- def length: Int
-
def
map[B](f: (A) ⇒ B): NonEmptyVector[B]
Applies f to all the elements
-
def
prepend[AA >: A](a: AA): NonEmptyVector[AA]
Prepend an item to this, producing a new
NonEmptyVector
. -
def
reduce[AA >: A](implicit S: Semigroup[AA]): AA
Reduce using the Semigroup of A
-
def
reduceLeft[AA >: A](f: (AA, AA) ⇒ AA): AA
Left-associative reduce using f.
- def reverse: NonEmptyVector[A]
-
def
show[AA >: A](implicit AA: Show[AA]): 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.
- def sortBy[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyVector[A]
- def sorted[AA >: A](implicit AA: Order[AA]): NonEmptyVector[AA]
- def tail: Vector[A]
-
def
toString(): String
- Definition Classes
- NonEmptyVector → Any
- val toVector: Vector[A]
-
def
updated[AA >: A](i: Int, a: AA): Option[NonEmptyVector[AA]]
Updates the element at the index, if it exists
-
def
updatedUnsafe[AA >: A](i: Int, a: AA): NonEmptyVector[AA]
Updates the element at the index, or throws an
IndexOutOfBoundsException
if none exists (ifi
does not satisfy0 <= i < length
). -
def
zipWith[B, C](b: NonEmptyVector[B])(f: (A, B) ⇒ C): NonEmptyVector[C]
Zips this
NonEmptyVector
with anotherNonEmptyVector
and applies a function for each pair of elements.Zips this
NonEmptyVector
with anotherNonEmptyVector
and applies a function for each pair of elements.scala> import cats.data.NonEmptyVector scala> val as = NonEmptyVector.of(1, 2, 3) scala> val bs = NonEmptyVector.of("A", "B", "C") scala> as.zipWith(bs)(_ + _) res0: cats.data.NonEmptyVector[String] = NonEmptyVector(1A, 2B, 3C)
- def zipWithIndex: NonEmptyVector[(A, Int)]