All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sageserpent.americium.java.CrossApiIterator.scala Maven / Gradle / Ivy

package com.sageserpent.americium.java

import java.util.Iterator as JavaIterator
import scala.collection.Iterator as ScalaIterator

object CrossApiIterator {
  def from[Element](
      underlying: ScalaIterator[Element]
  ): CrossApiIterator[Element] =
    new CrossApiIterator[Element] {
      override def hasNext: Boolean = underlying.hasNext
      override def next(): Element  = underlying.next()
    }
}

trait CrossApiIterator[Element]
    extends JavaIterator[Element]
    with ScalaIterator[Element] {
  source =>
  override def map[Transformed](
      transformation: Element => Transformed
  ): CrossApiIterator[Transformed] =
    new CrossApiIterator[Transformed] {
      override def hasNext: Boolean    = source.hasNext
      override def next(): Transformed = transformation(source.next())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy