sealed trait NonEmptyList[+A] extends NonEmptySeq[A, NonEmptyList, List]
A NonEmptyList[A] is a list of one or more values of type A. Unlike a
List, a NonEmptyList is guaranteed to contain at least one element.
This additional structure allows some operations to be defined on
NonEmptyList that are not safe on List, such as head and reduceAll.
For interoperability with Scala's collection library an implicit conversion
is provided from NonEmptyList to the :: case of List. Operations that
cannot preserve the guarantee that the resulting collection must have at
least one element will return a List instead.
- Self Type
- NonEmptyList[A]
- Alphabetic
- By Inheritance
- NonEmptyList
- NonEmptySeq
- NonEmptyOps
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def head: A
Returns the head of this
NonEmptyList.Returns the head of this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptyOps
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ++[A1 >: A](that: Iterable[A1]): NonEmptyList[A1]
Concatenates this
NonEmptyListwith the specifiedIterable. - final def ++[A1 >: A](that: NonEmptyList[A1]): NonEmptyList[A1]
Concatenates this
NonEmptyListwith the specifiedNonEmptyList. - final def ::[A1 >: A](a: A1): NonEmptyList[A1]
Prepends the specified value to this
NonEmptyList. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def appended[B >: A](elem: B): NonEmptyList[B]
Prepends the specified value to this
NonEmptyList.Prepends the specified value to this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptySeq
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def collect[B](pf: PartialFunction[A, B]): List[B]
Collects all elements of this
NonEmptyListthat match the specified partial function.Collects all elements of this
NonEmptyListthat match the specified partial function.- Definition Classes
- NonEmptyList → NonEmptyOps
- def collectFirst[B](pf: PartialFunction[A, B]): Option[B]
Selects the first element of this
NonEmptyListthat matches the specified partial function.Selects the first element of this
NonEmptyListthat matches the specified partial function.- Definition Classes
- NonEmptyList → NonEmptySeq
- final def contains[A1 >: A](a: A1)(implicit A: Equal[A1]): Boolean
Returns whether this
NonEmptyListcontains the specified element. - final def corresponds[B](that: NonEmptyList[B])(f: (A, B) => Boolean): Boolean
Determines whether this
NonEmptyListand the specifiedNonEmptyListhave the same length and every pair of corresponding elements of thisNonEmptyListand the specifiedNonEmptyListsatisfy the specified predicate.Determines whether this
NonEmptyListand the specifiedNonEmptyListhave the same length and every pair of corresponding elements of thisNonEmptyListand the specifiedNonEmptyListsatisfy the specified predicate.- Annotations
- @tailrec()
- final def count(f: (A) => Boolean): Int
Returns the number of elements in this
NonEmptyListthat satisfy the specified predicate. - final def distinct: NonEmptyList[A]
Removes duplicate elements from this
NonEmptyList.Removes duplicate elements from this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptySeq
- final def drop(n: Int): List[A]
Drops the first
nelements from thisNonEmptyListreturning aList.Drops the first
nelements from thisNonEmptyListreturning aList.- Annotations
- @tailrec()
- final def dropRight(n: Int): List[A]
Drops the last
nelements from thisNonEmptyListreturning aList. - final def dropWhile(f: (A) => Boolean): List[A]
Drops elements from the start of this
NonEmptyListthat satisfy the specified predicate returning aList.Drops elements from the start of this
NonEmptyListthat satisfy the specified predicate returning aList.- Annotations
- @tailrec()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def equals(that: Any): Boolean
Returns whether this
NonEmptyListand the specifiedNonEmptyListare equal to each other.Returns whether this
NonEmptyListand the specifiedNonEmptyListare equal to each other.- Definition Classes
- NonEmptyList → AnyRef → Any
- final def exists(f: (A) => Boolean): Boolean
Returns whether an element exists in this
NonEmptyListsatisfying the specified predicate.Returns whether an element exists in this
NonEmptyListsatisfying the specified predicate.- Definition Classes
- NonEmptyList → NonEmptyOps
- Annotations
- @tailrec()
- def filter(p: (A) => Boolean): List[A]
Filters elements of this
NonEmptyListthat satisfy the specified predicate.Filters elements of this
NonEmptyListthat satisfy the specified predicate.- Definition Classes
- NonEmptyList → NonEmptyOps
- def filterNot(p: (A) => Boolean): List[A]
Filters elements of this
NonEmptyListthat satisfy the specified predicate.Filters elements of this
NonEmptyListthat satisfy the specified predicate.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def find(f: (A) => Boolean): Option[A]
Returns the first element in this
NonEmptyListsatisfying the specified predicate orNoneotherwise.Returns the first element in this
NonEmptyListsatisfying the specified predicate orNoneotherwise.- Definition Classes
- NonEmptyList → NonEmptyOps
- Annotations
- @tailrec()
- final def flatMap[B](f: (A) => NonEmptyList[B]): NonEmptyList[B]
Transforms each element of this
NonEmptyListto aNonEmptyListand combines them into a singleNonEmptyList. - final def flatten[B](implicit ev: <:<[A, NonEmptyList[B]]): NonEmptyList[B]
Flattens a
NonEmptyListofNonEmptyListvalues into a singleNonEmptyList. - final def foldLeft[B](z: B)(f: (B, A) => B): B
Folds over the elements of this
NonEmptyListfrom left to right using the specified initial value and combining functionFolds over the elements of this
NonEmptyListfrom left to right using the specified initial value and combining function- Definition Classes
- NonEmptyList → NonEmptyOps
- Annotations
- @tailrec()
- final def foldRight[B](z: B)(op: (A, B) => B): B
Folds over the elements of this
NonEmptyListfrom right to left using the specified initial value and combining function. - final def forEach[F[+_], B](f: (A) => F[B])(implicit arg0: AssociativeBoth[F], arg1: Covariant[F]): F[NonEmptyList[B]]
Transforms each element of this
NonEmptyListwith the specified effectual function. - final def forall(f: (A) => Boolean): Boolean
Returns whether all elements of this
NonEmptyListsatisfy the specified predicate.Returns whether all elements of this
NonEmptyListsatisfy the specified predicate.- Definition Classes
- NonEmptyList → NonEmptyOps
- Annotations
- @tailrec()
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def grouped(size: Int): Iterator[NonEmptyList[A]]
Groups elements of this
NonEmptyListinto anIteratorofNonEmptyLists of the specified size.Groups elements of this
NonEmptyListinto anIteratorofNonEmptyLists of the specified size. The last group may be smaller than the specified size.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def hashCode(): Int
Returns the hashCode of this
NonEmptyList.Returns the hashCode of this
NonEmptyList.- Definition Classes
- NonEmptyList → AnyRef → Any
- def init: List[A]
- Definition Classes
- NonEmptyList → NonEmptyOps
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: Iterator[A]
Iterates over the elements of this
NonEmptyList.Iterates over the elements of this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptyOps
- def last: A
Returns the last element in this
NonEmptyList.Returns the last element in this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def length: Int
Returns the length of this
NonEmptyList. - final def map[B](f: (A) => B): NonEmptyList[B]
Transforms the elements of this
NonEmptyListwith the specified function.Transforms the elements of this
NonEmptyListwith the specified function.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def mapZIO[R, E, B](f: (A) => ZIO[R, E, B]): ZIO[R, E, NonEmptyList[B]]
Effectfully maps the elements of this
NonEmptyList. - final def mapZIOPar[R, E, B](f: (A) => ZIO[R, E, B]): ZIO[R, E, NonEmptyList[B]]
Effectfully maps the elements of this
NonEmptyListin parallel. - final def max(implicit A: Ord[A]): A
Returns the maximum element in this
NonEmptyList. - final def maxBy[B](f: (A) => B)(implicit B: Ord[B]): A
Returns the maximum element in this
NonEmptyListusing the specified function to map values of typeAto values of typeBthat an ordering is defined on. - final def min(implicit A: Ord[A]): A
Returns the minimum element in this
NonEmptyList. - final def minBy[B](f: (A) => B)(implicit B: Ord[B]): A
Returns the minimum element in this
NonEmptyListusing the specified function to map values of typeAto values of typeBthat an ordering is defined on. - final def mkString(start: String, sep: String, end: String): String
Renders the elements of this
NonEmptyListas aStringusing the specified separator and start and end values. - final def mkString(sep: String): String
Renders the elements of this
NonEmptyListas aStringusing the specified separator. - final def mkString: String
Renders the elements of this
NonEmptyListas aString. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def peel: (A, List[A])
Decomposes the
NonEmptyListinto an element and a (possibly empty)List - final def peelNonEmpty: (A, Option[NonEmptyList[A]])
Returns an element of this
NonEmptyListand the remainder orNone, if the remainder is empty. - def prepended[B >: A](elem: B): NonEmptyList[B]
Prepends the specified value to this
NonEmptyList.Prepends the specified value to this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptySeq
- final def product[A1 >: A](implicit A: Associative[Prod[A1]]): A1
Returns the product of the elements of this
NonEmptyList. - def reduce[B >: A](op: (B, B) => B): B
Reduces the elements of this
NonEmptyListfrom left to right using the specified function.Reduces the elements of this
NonEmptyListfrom left to right using the specified function.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def reduce[A1 >: A](implicit A: Associative[A1]): A1
Reduces the elements of this
NonEmptyListusing the specified associative operator. - final def reduceLeft[A1 >: A](f: (A1, A1) => A1): A1
Reduces the elements of this
NonEmptyListfrom left to right using the specified function. - final def reduceMap[B](f: (A) => B)(implicit B: Associative[B]): B
Maps each element of this
NonEmptyListto a typeBthat has an associative operation then combines them all with the associative operation. - final def reduceMapLeft[B](map: (A) => B)(reduce: (B, A) => B): B
Reduces the elements of this
NonEmptyListfrom left to right using the functionmapto transform the first value to the typeBand then the functionreduceAllto combine theBvalue with each otherAvalue. - final def reduceMapRight[B](map: (A) => B)(reduce: (A, B) => B): B
Reduces the elements of this
NonEmptyListfrom right to left using the functionmapto transform the first value to the typeBand then the functionreduceAllto combine theBvalue with each otherAvalue. - final def reduceRight[A1 >: A](f: (A1, A1) => A1): A1
Reduces the elements of this
NonEmptyListfrom right to left using the specified function. - final def reverse: NonEmptyList[A]
Reverses the order of elements in this
NonEmptyList.Reverses the order of elements in this
NonEmptyList.- Definition Classes
- NonEmptyList → NonEmptySeq
- def size: Int
- Definition Classes
- NonEmptyOps
- def sortBy[B](f: (A) => B)(implicit ord: scala.Ordering[B]): NonEmptyList[A]
- Definition Classes
- NonEmptyList → NonEmptySeq
- def sorted[B >: A](implicit ord: scala.Ordering[B]): NonEmptyList[B]
- Definition Classes
- NonEmptyList → NonEmptySeq
- final def sum[A1 >: A](implicit A: Associative[Sum[A1]]): A1
Returns the sum of the elements of this
NonEmptyList. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tail: List[A]
- Definition Classes
- NonEmptyList → NonEmptyOps
- final def tailNonEmpty: Option[NonEmptyList[A]]
Returns the tail of this
NonEmptyListif it exists orNoneotherwise. - final def tails: NonEmptyList[NonEmptyList[A]]
Returns a new
NonEmptyListcomposed of thisNonEmptyListfollowed by each of its tails, ending with a singletonNonEmptyList. - final def take(n: Int): List[A]
Takes the first
nelements from thisNonEmptyListreturning aList. - final def takeRight(n: Int): List[A]
Takes the last
nelements from thisNonEmptyListreturning aList. - final def takeWhile(f: (A) => Boolean): List[A]
Takes elements from the start of this
NonEmptyListthat satisfy the specified predicate returning aList. - def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]
- Definition Classes
- NonEmptyList → NonEmptyOps
- final def toCons[A1 >: A]: ::[A1]
Converts this
NonEmptyListto the::case of aList. - def toIterable: Iterable[A]
- Definition Classes
- NonEmptyList → NonEmptyOps
- def toList: List[A]
- Definition Classes
- NonEmptyList → NonEmptyOps
- final def toNonEmptyChunk: NonEmptyChunk[A]
Converts this
NonEmptyListto aNonEmptyChunk. - final def toString(): String
Renders this
NonEmptyListas aString.Renders this
NonEmptyListas aString.- Definition Classes
- NonEmptyList → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def zip[B](that: NonEmptyList[B])(implicit zippable: Zippable[A, B]): NonEmptyList[Out]
Zips this
NonEmptyListtogether with the specifiedNonEmptyList, returning a newNonEmptyListwith a length equal to the minimum of the two and elements combined pairwise.Zips this
NonEmptyListtogether with the specifiedNonEmptyList, returning a newNonEmptyListwith a length equal to the minimum of the two and elements combined pairwise.- Definition Classes
- NonEmptyList → NonEmptyOps
- final def zipWith[B, C](that: NonEmptyList[B])(f: (A, B) => C): NonEmptyList[C]
Zips this
NonEmptyListtogether with the specifiedNonEmptyList, returning a newNonEmptyListwith a length equal to the minimum of the two and elements combined pairwise using the specified function. - final def zipWithIndex: NonEmptyList[(A, Int)]
Annotates each element of this
NonEmptyListwith its index.Annotates each element of this
NonEmptyListwith its index.- Definition Classes
- NonEmptyList → NonEmptyOps