Packages

final class NonEmptySeq[+A] extends AnyVal with NonEmptyCollection[A, Seq, NonEmptySeq]

A data type which represents a Seq guaranteed to contain at least one element.
Note that the constructor is private to prevent accidental construction of an empty NonEmptySeq. However, due to https://issues.scala-lang.org/browse/SI-6601, on Scala 2.10, this may be bypassed due to a compiler bug.

Source
NonEmptySeq.scala
Linear Supertypes
NonEmptyCollection[A, Seq, NonEmptySeq], AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NonEmptySeq
  2. NonEmptyCollection
  3. AnyVal
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. def ++[AA >: A](other: Seq[AA]): NonEmptySeq[AA]

    Alias for concat

  4. def ++:[AA >: A](other: NonEmptySeq[AA]): NonEmptySeq[AA]

    Append this NESeq to another NESeq, producing a new NonEmptySeq.

    Append this NESeq to another NESeq, producing a new NonEmptySeq.

    scala> import cats.data.NonEmptySeq
    scala> val neSeq = NonEmptySeq.of(1, 2, 3)
    scala> neSeq ++: NonEmptySeq.of(4, 5)
    res0: cats.data.NonEmptySeq[Int] = NonEmptySeq(1, 2, 3, 4, 5)
  5. def +:[AA >: A](a: AA): NonEmptySeq[AA]

    Alias for prepend

  6. def :+[AA >: A](a: AA): NonEmptySeq[AA]

    Alias for append

  7. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  8. def ===[AA >: A](that: NonEmptySeq[AA])(implicit A: Eq[AA]): Boolean

    Typesafe equality operator.

    Typesafe equality operator.

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

  9. def append[AA >: A](a: AA): NonEmptySeq[AA]

    Append an item to this, producing a new NonEmptySeq.

    Append an item to this, producing a new NonEmptySeq.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def collect[B](pf: PartialFunction[A, B]): Seq[B]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  12. def concat[AA >: A](other: Seq[AA]): NonEmptySeq[AA]

    Append another Seq to this, producing a new NonEmptySeq.

  13. def concatNeSeq[AA >: A](other: NonEmptySeq[AA]): NonEmptySeq[AA]

    Append another NonEmptySeq to this, producing a new NonEmptySeq.

  14. def distinct[AA >: A](implicit O: Order[AA]): NonEmptySeq[AA]

    Remove duplicates.

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

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  15. def exists(f: (A) ⇒ Boolean): Boolean

    Check whether at least one element satisfies the predicate.

    Check whether at least one element satisfies the predicate.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  16. def filter(f: (A) ⇒ Boolean): Seq[A]

    Remove elements not matching the predicate

    Remove elements not matching the predicate

    scala> import cats.data.NonEmptySeq
    scala> val neSeq = NonEmptySeq.of(1, 2, 3, 4, 5)
    scala> neSeq.filter(_ < 3)
    res0: scala.collection.immutable.Seq[Int] = List(1, 2)
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  17. def filterNot(f: (A) ⇒ Boolean): Seq[A]

    Remove elements matching the predicate

    Remove elements matching the predicate

    scala> import cats.data.NonEmptySeq
    scala> val neSeq = NonEmptySeq.of(1, 2, 3, 4, 5)
    scala> neSeq.filterNot(_ < 3)
    res0: scala.collection.immutable.Seq[Int] = List(3, 4, 5)
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  18. def find(f: (A) ⇒ Boolean): Option[A]

    Find the first element matching the predicate, if one exists

    Find the first element matching the predicate, if one exists

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  19. def flatMap[B](f: (A) ⇒ NonEmptySeq[B]): NonEmptySeq[B]

    Applies f to all elements and combines the result

  20. def foldLeft[B](b: B)(f: (B, A) ⇒ B): B

    Left-associative fold using f.

    Left-associative fold using f.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  21. def foldRight[B](lb: Eval[B])(f: (A, Eval[B]) ⇒ Eval[B]): Eval[B]

    Right-associative fold using f.

  22. def forall(f: (A) ⇒ Boolean): Boolean

    Check whether all elements satisfy the predicate.

    Check whether all elements satisfy the predicate.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  23. def get(i: Int): Option[A]

    Gets the element at the index, if it exists

  24. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  25. def getUnsafe(i: Int): A

    Gets the element at the index, or throws an exception if none exists

  26. final def groupBy[B](f: (A) ⇒ B)(implicit B: Order[B]): SortedMap[B, NonEmptySeq[A]]

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

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

    scala> import scala.collection.immutable.SortedMap
    scala> import cats.data.NonEmptySeq
    scala> import cats.implicits._
    scala> val neSeq = NonEmptySeq.of(12, -2, 3, -5)
    scala> val expectedResult = SortedMap(false -> NonEmptySeq.of(-2, -5), true -> NonEmptySeq.of(12, 3))
    scala> val result = neSeq.groupBy(_ >= 0)
    scala> result === expectedResult
    res0: Boolean = true
  27. final def groupByNem[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptyMap[B, NonEmptySeq[A]]

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

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

    scala> import cats.data.{NonEmptyMap, NonEmptySeq}
    scala> import cats.implicits._
    scala> val nel = NonEmptySeq.of(12, -2, 3, -5)
    scala> val expectedResult = NonEmptyMap.of(false -> NonEmptySeq.of(-2, -5), true -> NonEmptySeq.of(12, 3))
    scala> val result = nel.groupByNem(_ >= 0)
    scala> result === expectedResult
    res0: Boolean = true
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  28. def grouped(size: Int): Iterator[NonEmptySeq[A]]

    Partitions elements in fixed size NonEmptySeqs.

    Partitions elements in fixed size NonEmptySeqs.

    scala> import cats.data.NonEmptySeq
    scala> import cats.implicits._
    scala> val nel = NonEmptySeq.of(12, -2, 3, -5)
    scala> val expectedResult = List(NonEmptySeq.of(12, -2), NonEmptySeq.of(3, -5))
    scala> val result = nel.grouped(2)
    scala> result.toList === expectedResult
    res0: Boolean = true
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  29. def head: A
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  30. def init: Seq[A]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  31. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  32. final def iterator: Iterator[A]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  33. def last: A
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  34. def length: Int
  35. def map[B](f: (A) ⇒ B): NonEmptySeq[B]

    Applies f to all the elements

    Applies f to all the elements

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  36. def prepend[AA >: A](a: AA): NonEmptySeq[AA]

    Prepend an item to this, producing a new NonEmptySeq.

    Prepend an item to this, producing a new NonEmptySeq.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  37. def prependSeq[AA >: A](Seq: Seq[AA]): NonEmptySeq[AA]

    Prepend a Seq to this, producing a new NonEmptySeq.

  38. def reduce[AA >: A](implicit S: Semigroup[AA]): AA

    Reduce using the Semigroup of A

    Reduce using the Semigroup of A

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  39. def reduceLeft[AA >: A](f: (AA, AA) ⇒ AA): AA

    Left-associative reduce using f.

  40. def reverse: NonEmptySeq[A]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  41. 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.

    Definition Classes
    NonEmptySeq → NonEmptyCollection
  42. def sortBy[B](f: (A) ⇒ B)(implicit B: Order[B]): NonEmptySeq[A]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  43. def sorted[AA >: A](implicit AA: Order[AA]): NonEmptySeq[AA]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  44. def tail: Seq[A]
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  45. final def toNem[T, U](implicit ev: <:<[A, (T, U)], order: Order[T]): NonEmptyMap[T, U]

    Creates new NonEmptyMap, similarly to List#toMap from scala standard library.

    Creates new NonEmptyMap, similarly to List#toMap from scala standard library.

    scala> import cats.data.{NonEmptyMap, NonEmptySeq}
    scala> import cats.implicits._
    scala> import scala.collection.immutable.Seq
    scala> val neSeq = NonEmptySeq((0, "a"), Seq((1, "b"),(0, "c"), (2, "d")))
    scala> val expectedResult = NonEmptyMap.of(0 -> "c", 1 -> "b", 2 -> "d")
    scala> val result = neSeq.toNem
    scala> result === expectedResult
    res0: Boolean = true
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  46. final def toNes[B >: A](implicit order: Order[B]): NonEmptySet[B]

    Creates new NonEmptySet, similarly to List#toSet from scala standard library.

    Creates new NonEmptySet, similarly to List#toSet from scala standard library.

    scala> import cats.data._
    scala> import cats.instances.int._
    scala> import scala.collection.immutable.Seq
    scala> val neSeq = NonEmptySeq(1, Seq(2,2,3,4))
    scala> neSeq.toNes
    res0: cats.data.NonEmptySet[Int] = TreeSet(1, 2, 3, 4)
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  47. val toSeq: Seq[A]
  48. def toString(): String
    Definition Classes
    NonEmptySeq → Any
  49. def updated[AA >: A](i: Int, a: AA): Option[NonEmptySeq[AA]]

    Updates the element at the index, if it exists

  50. def updatedUnsafe[AA >: A](i: Int, a: AA): NonEmptySeq[AA]

    Updates the element at the index, or throws an IndexOutOfBoundsException if none exists (if i does not satisfy 0 <= i < length).

  51. def zipWith[B, C](b: NonEmptySeq[B])(f: (A, B) ⇒ C): NonEmptySeq[C]

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

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

    scala> import cats.data.NonEmptySeq
    scala> val as = NonEmptySeq.of(1, 2, 3)
    scala> val bs = NonEmptySeq.of("A", "B", "C")
    scala> as.zipWith(bs)(_.toString + _)
    res0: cats.data.NonEmptySeq[String] = NonEmptySeq(1A, 2B, 3C)
    Definition Classes
    NonEmptySeq → NonEmptyCollection
  52. def zipWithIndex: NonEmptySeq[(A, Int)]
    Definition Classes
    NonEmptySeq → NonEmptyCollection

Inherited from NonEmptyCollection[A, Seq, NonEmptySeq]

Inherited from AnyVal

Inherited from Any

Ungrouped