sealed abstract class Chain[+A] extends AnyRef
Trivial catenable sequence. Supports O(1) append, and (amortized)
O(1) uncons
, such that walking the sequence via N successive uncons
steps takes O(N).
- Source
- Chain.scala
- Alphabetic
- By Inheritance
- Chain
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
++[A2 >: A](c: Chain[A2]): Chain[A2]
Alias for concat
-
final
def
+:[A2 >: A](a: A2): Chain[A2]
Alias for prepend.
-
final
def
:+[A2 >: A](a: A2): Chain[A2]
Alias for append.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
===[AA >: A](that: Chain[AA])(implicit A: Eq[AA]): Boolean
Typesafe equality operator.
Typesafe equality operator.
This method is similar to == except that it only allows two Chain[A] values to be compared to each other, and uses equality provided by Eq[_] instances, rather than using the universal equality provided by .equals.
-
final
def
append[A2 >: A](a: A2): Chain[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
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @IntrinsicCandidate()
-
final
def
collect[B](pf: PartialFunction[A, B]): Chain[B]
Collect
B
from this for whichf
is defined -
final
def
collectFirst[B](pf: PartialFunction[A, B]): Option[B]
Finds the first element of this
Chain
for which the given partial function is defined, and applies the partial function to it. -
final
def
collectFirstSome[B](f: (A) ⇒ Option[B]): Option[B]
Like
collectFirst
fromscala.collection.Traversable
but takesA => Option[B]
instead ofPartialFunction
s. -
final
def
concat[A2 >: A](c: Chain[A2]): Chain[A2]
Concatenates this with
c
in O(1) runtime. -
final
def
contains[AA >: A](a: AA)(implicit A: Eq[AA]): Boolean
Check whether an element is in this structure
-
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. -
def
distinct[AA >: A](implicit O: Order[AA]): Chain[AA]
Remove duplicates.
Remove duplicates. Duplicates are checked using
Order[_]
instance. -
final
def
dropWhile(p: (A) ⇒ Boolean): Chain[A]
Drops longest prefix of elements that satisfy a predicate.
Drops longest prefix of elements that satisfy a predicate.
- p
The predicate used to test elements.
- returns
the longest suffix of this sequence whose first element does not satisfy the predicate p.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(o: Any): Boolean
- Definition Classes
- Chain → AnyRef → Any
-
final
def
exists(f: (A) ⇒ Boolean): Boolean
Check whether at least one element satisfies the predicate
-
final
def
filter(f: (A) ⇒ Boolean): Chain[A]
Remove elements not matching the predicate
-
final
def
filterNot(f: (A) ⇒ Boolean): Chain[A]
Remove elements matching the predicate
-
final
def
find(f: (A) ⇒ Boolean): Option[A]
Find the first element matching the predicate, if one exists
-
final
def
flatMap[B](f: (A) ⇒ Chain[B]): Chain[B]
Applies the supplied function to each element and returns a new Chain from the concatenated results
-
final
def
foldLeft[B](z: B)(f: (B, A) ⇒ B): B
Folds over the elements from left to right using the supplied initial value and function.
-
final
def
foldRight[B](z: B)(f: (A, B) ⇒ B): B
Folds over the elements from right to left using the supplied initial value and function.
-
final
def
forall(f: (A) ⇒ Boolean): Boolean
Check whether all elements satisfy the predicate
- final def get(idx: Long): Option[A]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
groupBy[B](f: (A) ⇒ B)(implicit B: Order[B]): SortedMap[B, NonEmptyChain[A]]
Groups elements inside this
Chain
according to theOrder
of the keys produced by the given mapping function.Groups elements inside this
Chain
according to theOrder
of the keys produced by the given mapping function.scala> import scala.collection.immutable.SortedMap scala> import cats.data.{Chain, NonEmptyChain} scala> import cats.implicits._ scala> val chain = Chain(12, -2, 3, -5) scala> val expectedResult = SortedMap(false -> NonEmptyChain(-2, -5), true -> NonEmptyChain(12, 3)) scala> val result = chain.groupBy(_ >= 0) scala> result === expectedResult res0: Boolean = true
-
final
def
groupMap[K, B](key: (A) ⇒ K)(f: (A) ⇒ B)(implicit K: Order[K]): SortedMap[K, NonEmptyChain[B]]
Groups elements inside this
Chain
according to theOrder
of the keys produced by the given key function.Groups elements inside this
Chain
according to theOrder
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 scala.collection.immutable.SortedMap scala> import cats.data.{Chain, NonEmptyChain} scala> import cats.implicits._ scala> val chain = Chain(12, -2, 3, -5) scala> val expectedResult = SortedMap(false -> NonEmptyChain("-2", "-5"), true -> NonEmptyChain("12", "3")) scala> val result = chain.groupMap(_ >= 0)(_.toString) scala> result === expectedResult res0: Boolean = true
-
final
def
groupMapReduce[K, B](key: (A) ⇒ K)(f: (A) ⇒ B)(implicit K: Order[K], S: Semigroup[B]): SortedMap[K, B]
Groups elements inside this
Chain
according to theOrder
of the keys produced by the given key function.Groups elements inside this
Chain
according to theOrder
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 theirSemigroup
scala> import scala.collection.immutable.SortedMap scala> import cats.data.Chain scala> import cats.implicits._ scala> val chain = Chain("Hello", "World", "Goodbye", "World") scala> val expectedResult = SortedMap("goodbye" -> 1, "hello" -> 1, "world" -> 2) scala> val result = chain.groupMapReduce(_.trim.toLowerCase)(_ => 1) scala> result === expectedResult res0: Boolean = true
-
final
def
groupMapReduceWith[K, B](key: (A) ⇒ K)(f: (A) ⇒ B)(combine: (B, B) ⇒ B)(implicit K: Order[K]): SortedMap[K, B]
Groups elements inside this
Chain
according to theOrder
of the keys produced by the given key function.Groups elements inside this
Chain
according to theOrder
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 scala.collection.immutable.SortedMap scala> import cats.data.Chain scala> import cats.implicits._ scala> val chain = Chain("Hello", "World", "Goodbye", "World") scala> val expectedResult = SortedMap("goodbye" -> 1, "hello" -> 1, "world" -> 2) scala> val result = chain.groupMapReduceWith(_.trim.toLowerCase)(_ => 1)(_ + _) scala> result === expectedResult res0: Boolean = true
- def hash[AA >: A](implicit hashA: Hash[AA]): Int
-
def
hashCode(): Int
- Definition Classes
- Chain → AnyRef → Any
-
def
headOption: Option[A]
Returns the head of this Chain if non empty, none otherwise.
Returns the head of this Chain if non empty, none otherwise. Amortized O(1).
-
final
def
initLast: Option[(Chain[A], A)]
Returns the init and last of this Chain if non empty, none otherwise.
Returns the init and last of this Chain if non empty, none otherwise. Amortized O(1).
-
def
isEmpty: Boolean
Returns true if there are no elements in this collection.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def iterator: Iterator[A]
-
final
def
lastOption: Option[A]
Returns the last of this Chain if non empty, none otherwise.
Returns the last of this Chain if non empty, none otherwise. Amortized O(1).
-
final
def
length: Long
Returns the number of elements in this structure
-
final
def
map[B](f: (A) ⇒ B): Chain[B]
Applies the supplied function to each element and returns a new Chain.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
nonEmpty: Boolean
Returns false if there are no elements in this collection.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
prepend[A2 >: A](a: A2): Chain[A2]
Returns a new Chain consisting of
a
followed by this.Returns a new Chain consisting of
a
followed by this. O(1) runtime. -
def
reverse: Chain[A]
Reverses this
Chain
- final def reverseIterator: Iterator[A]
- def show[AA >: A](implicit AA: Show[AA]): String
-
final
def
size: Long
Alias for length
- final def sortBy[B](f: (A) ⇒ B)(implicit B: Order[B]): Chain[A]
- final def sorted[AA >: A](implicit AA: Order[AA]): Chain[AA]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
takeWhile(p: (A) ⇒ Boolean): Chain[A]
Takes longest prefix of elements that satisfy a predicate.
Takes longest prefix of elements that satisfy a predicate.
- p
The predicate used to test elements.
- returns
the longest prefix of this chain whose elements all satisfy the predicate p.
-
final
def
toList: List[A]
Converts to a list.
-
def
toString(): String
- Definition Classes
- Chain → AnyRef → Any
-
final
def
toVector: Vector[A]
Converts to a vector.
-
final
def
uncons: Option[(A, Chain[A])]
Returns the head and tail of this Chain if non empty, none otherwise.
Returns the head and tail of this Chain if non empty, none otherwise. Amortized O(1).
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
zipWith[B, C](other: Chain[B])(f: (A, B) ⇒ C): Chain[C]
Zips this
Chain
with anotherChain
and applies a function for each pair of elements. -
final
def
zipWithIndex: Chain[(A, Int)]
Zips each element of this
Chain
with its index.