"Fossies" - the Fresh Open Source Software Archive

Member "scala-js-1.0.0-RC1/junit-runtime/src/main/scala/org/hamcrest/internal/ArrayIterator.scala" (21 Nov 2019, 769 Bytes) of package /linux/www/scala-js-1.0.0-RC1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scala source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Ported from https://github.com/hamcrest/JavaHamcrest/
    3  */
    4 package org.hamcrest.internal
    5 
    6 import java.{util => ju}
    7 
    8 class ArrayIterator private (array: Array[_], private var currentIndex: Int = 0)
    9     extends ju.Iterator[AnyRef] {
   10 
   11   def this(array: AnyRef) = {
   12     this(
   13       array match {
   14         case arr: Array[_] => arr
   15         case _ => throw new IllegalArgumentException("not an array")
   16       },
   17       0
   18     )
   19   }
   20 
   21   override def hasNext: Boolean =
   22     currentIndex < array.length
   23 
   24   override def next(): AnyRef = {
   25     val _currentIndex = currentIndex
   26     currentIndex = _currentIndex + 1
   27     array(_currentIndex).asInstanceOf[AnyRef]
   28   }
   29 
   30   override def remove(): Unit =
   31     throw new UnsupportedOperationException("cannot remove items from an array")
   32 }