This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

FixedPointCollection.scala 437 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package de.bbisping.coupledsim.util

class FixedPointCollection[A](step: (Iterable[A]) => Iterable[A]) {
  def apply(initial: Iterable[A]): Iterable[A] = {
    val newValues = step(initial)
    if (newValues.isEmpty) {
      initial
    } else {
      initial ++ apply(newValues)
    }
  }
}

object FixedPointCollection {
  def apply[A](step: (Iterable[A]) => Iterable[A]): FixedPointCollection[A] =
    new FixedPointCollection(step)
}