Skip to content

Commit

Permalink
Remove redundant benchmarking methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Luka Jacobowitz committed Aug 13, 2018
1 parent 257a7a9 commit 58caa4e
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ sealed abstract class Chain[+A] {
final def map[B](f: A => B): Chain[B] =
fromSeq(iterator.map(f).toVector)

/** Applies the supplied function to each element and returns a new Chain from the concatenated results */
final def flatMap[B](f: A => Chain[B]): Chain[B] =
foldLeft(nil: Chain[B])((acc, a) => acc ++ f(a))

/** Applies the supplied function to each element and returns a new Chain from the concatenated results */
final def flatMapIterator[B](f: A => Chain[B]): Chain[B] = {
final def flatMap[B](f: A => Chain[B]): Chain[B] = {
var result = empty[B]
val iter = iterator
while (iter.hasNext) { result = result ++ f(iter.next) }
Expand Down Expand Up @@ -131,16 +128,6 @@ sealed abstract class Chain[+A] {
result
}

final def findIterator(f: A => Boolean): Option[A] = {
val iter = iterator
var result: Option[A] = Option.empty[A]
while (iter.hasNext && result.isEmpty) {
val a = iter.next
if (f(a)) result = Some(a)
}
result
}

/** Check whether at least one element satisfies the predicate */
final def exists(f: A => Boolean): Boolean = {
var result: Boolean = false
Expand Down Expand Up @@ -189,21 +176,6 @@ sealed abstract class Chain[+A] {
final def groupBy[B](f: A => B)(implicit B: Order[B]): SortedMap[B, Chain[A]] = {
implicit val ordering: Ordering[B] = B.toOrdering
var m = SortedMap.empty[B, Chain[A]]

foreach { elem =>
val k = f(elem)

m.get(k) match {
case None => m += ((k, one(elem))); ()
case Some(cat) => m = m.updated(k, cat :+ elem)
}
}
m
}

final def groupByIterator[B](f: A => B)(implicit B: Order[B]): SortedMap[B, Chain[A]] = {
implicit val ordering: Ordering[B] = B.toOrdering
var m = SortedMap.empty[B, Chain[A]]
val iter = iterator

while (iter.hasNext) {
Expand Down

0 comments on commit 58caa4e

Please sign in to comment.