Created
July 4, 2010 16:41
-
-
Save alexeyr/463565 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scalaz | |
| import scala.collection.IndexedSeq | |
| import reflect.ClassManifest | |
| import collection.{IndexedSeqLike, IndexedSeqOptimized} | |
| import scala.collection.generic._ | |
| import collection.mutable.{ArrayBuffer, ArrayBuilder, Builder} | |
| /** | |
| * An immutable wrapper for arrays | |
| * | |
| * @tparam A type of the elements of the array | |
| */ | |
| abstract class ImmutableArray[+A] extends IndexedSeq[A] with IndexedSeqOptimized[A, ImmutableArray[A]] { | |
| protected[this] def elemManifest: ClassManifest[A] | |
| override def stringPrefix = "ImmutableArray" | |
| // override def companion = ImmutableArray | |
| } | |
| object ImmutableArray extends GenericCompanion[IndexedSeq] { | |
| def make[A](x: AnyRef): ImmutableArray[A] = { | |
| val y = x match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case x: Array[AnyRef] => new ofRef(x) | |
| case x: String => new StringArray(x) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| /** Gives better type inference than make[A] */ | |
| def fromArray[A](x: Array[A]): ImmutableArray[A] = { | |
| val y = x.asInstanceOf[AnyRef] match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case y: Array[AnyRef] => new ofRef(x.asInstanceOf[Array[AnyRef]]) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| // override def newBuilder[A]: Builder[A, ImmutableArray[A]] = newBuilder(implicitly[ClassManifest[A]]) | |
| // def newBuilder[A]: Builder[A, ImmutableArray[A]] = (new ArrayBuffer[A]).mapResult(b => fromArray(b.toArray)) | |
| // override def newBuilder[A]: Builder[A, scala.collection.IndexedSeq[A]] = new ArrayBuffer[A] | |
| def newBuilder[A](elemManifest: ClassManifest[A]): Builder[A, ImmutableArray[A]] = | |
| ArrayBuilder.make[A]()(elemManifest).mapResult(make(_)) | |
| abstract class ImmutableArray1[+A](array: Array[A]) extends ImmutableArray[A] { | |
| private[this] val arr = array.clone | |
| override def stringPrefix = "ImmutableArray" | |
| override protected[this] def newBuilder = ImmutableArray.newBuilder[A](elemManifest) | |
| def apply(idx: Int) = arr(idx) | |
| def length = arr.length | |
| override def toArray[B >: A : ClassManifest]: Array[B] = arr.clone.asInstanceOf[Array[B]] | |
| override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { | |
| var l = len | |
| if (arr.length < l) l = arr.length | |
| if (xs.length - start < l) l = xs.length - start max 0 | |
| Array.copy(arr, 0, xs, start, l) | |
| } | |
| } | |
| final class ofRef[+T <: AnyRef](array: Array[T]) extends ImmutableArray1[T](array) { | |
| protected[this] lazy val elemManifest = ClassManifest.classType[T](array.getClass.getComponentType) | |
| } | |
| final class ofByte(array: Array[Byte]) extends ImmutableArray1[Byte](array) { | |
| protected[this] def elemManifest = ClassManifest.Byte | |
| } | |
| final class ofShort(array: Array[Short]) extends ImmutableArray1[Short](array) { | |
| protected[this] def elemManifest = ClassManifest.Short | |
| } | |
| final class ofChar(array: Array[Char]) extends ImmutableArray1[Char](array) { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| } | |
| final class ofInt(array: Array[Int]) extends ImmutableArray1[Int](array) { | |
| protected[this] def elemManifest = ClassManifest.Int | |
| } | |
| final class ofLong(array: Array[Long]) extends ImmutableArray1[Long](array) { | |
| protected[this] def elemManifest = ClassManifest.Long | |
| } | |
| final class ofFloat(array: Array[Float]) extends ImmutableArray1[Float](array) { | |
| protected[this] def elemManifest = ClassManifest.Float | |
| } | |
| final class ofDouble(array: Array[Double]) extends ImmutableArray1[Double](array) { | |
| protected[this] def elemManifest = ClassManifest.Double | |
| } | |
| final class ofBoolean(array: Array[Boolean]) extends ImmutableArray1[Boolean](array) { | |
| protected[this] def elemManifest = ClassManifest.Boolean | |
| } | |
| final class ofUnit(array: Array[Unit]) extends ImmutableArray1[Unit](array) { | |
| protected[this] def elemManifest = ClassManifest.Unit | |
| } | |
| final class StringArray(val str: String) extends ImmutableArray[Char] { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| override protected[this] def newBuilder = (new StringBuilder).mapResult(new StringArray(_)) | |
| def apply(idx: Int) = str(idx) | |
| def length = str.length | |
| override def toArray[B >: Char : ClassManifest]: Array[B] = str.toArray | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scalaz | |
| import scala.collection.IndexedSeq | |
| import reflect.ClassManifest | |
| import collection.{IndexedSeqLike, IndexedSeqOptimized} | |
| import scala.collection.generic._ | |
| import collection.mutable.{ArrayBuffer, ArrayBuilder, Builder} | |
| /** | |
| * An immutable wrapper for arrays | |
| * | |
| * @tparam A type of the elements of the array | |
| */ | |
| abstract class ImmutableArray[+A] extends IndexedSeqOptimized[A, ImmutableArray[A]] { | |
| protected[this] def elemManifest: ClassManifest[A] | |
| override def stringPrefix = "ImmutableArray" | |
| // override def companion = ImmutableArray | |
| } | |
| object ImmutableArray extends GenericCompanion[IndexedSeq] { | |
| def make[A](x: AnyRef): ImmutableArray[A] = { | |
| val y = x match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case x: Array[AnyRef] => new ofRef(x) | |
| case x: String => new StringArray(x) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| /** Gives better type inference than make[A] */ | |
| def fromArray[A](x: Array[A]): ImmutableArray[A] = { | |
| val y = x.asInstanceOf[AnyRef] match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case y: Array[AnyRef] => new ofRef(x.asInstanceOf[Array[AnyRef]]) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| // override def newBuilder[A]: Builder[A, ImmutableArray[A]] = newBuilder(implicitly[ClassManifest[A]]) | |
| // def newBuilder[A]: Builder[A, ImmutableArray[A]] = (new ArrayBuffer[A]).mapResult(b => fromArray(b.toArray)) | |
| override def newBuilder[A]: Builder[A, scala.collection.IndexedSeq[A]] = new ArrayBuffer[A] | |
| def newBuilder[A](elemManifest: ClassManifest[A]): Builder[A, ImmutableArray[A]] = | |
| ArrayBuilder.make[A]()(elemManifest).mapResult(make(_)) | |
| abstract class ImmutableArray1[+A](array: Array[A]) extends ImmutableArray[A] { | |
| private[this] val arr = array.clone | |
| override def stringPrefix = "ImmutableArray" | |
| override protected[this] def newBuilder = ImmutableArray.newBuilder[A](elemManifest) | |
| def apply(idx: Int) = arr(idx) | |
| def length = arr.length | |
| override def toArray[B >: A : ClassManifest]: Array[B] = arr.clone.asInstanceOf[Array[B]] | |
| override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { | |
| var l = len | |
| if (arr.length < l) l = arr.length | |
| if (xs.length - start < l) l = xs.length - start max 0 | |
| Array.copy(arr, 0, xs, start, l) | |
| } | |
| } | |
| final class ofRef[+T <: AnyRef](array: Array[T]) extends ImmutableArray1[T](array) { | |
| protected[this] lazy val elemManifest = ClassManifest.classType[T](array.getClass.getComponentType) | |
| } | |
| final class ofByte(array: Array[Byte]) extends ImmutableArray1[Byte](array) { | |
| protected[this] def elemManifest = ClassManifest.Byte | |
| } | |
| final class ofShort(array: Array[Short]) extends ImmutableArray1[Short](array) { | |
| protected[this] def elemManifest = ClassManifest.Short | |
| } | |
| final class ofChar(array: Array[Char]) extends ImmutableArray1[Char](array) { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| } | |
| final class ofInt(array: Array[Int]) extends ImmutableArray1[Int](array) { | |
| protected[this] def elemManifest = ClassManifest.Int | |
| } | |
| final class ofLong(array: Array[Long]) extends ImmutableArray1[Long](array) { | |
| protected[this] def elemManifest = ClassManifest.Long | |
| } | |
| final class ofFloat(array: Array[Float]) extends ImmutableArray1[Float](array) { | |
| protected[this] def elemManifest = ClassManifest.Float | |
| } | |
| final class ofDouble(array: Array[Double]) extends ImmutableArray1[Double](array) { | |
| protected[this] def elemManifest = ClassManifest.Double | |
| } | |
| final class ofBoolean(array: Array[Boolean]) extends ImmutableArray1[Boolean](array) { | |
| protected[this] def elemManifest = ClassManifest.Boolean | |
| } | |
| final class ofUnit(array: Array[Unit]) extends ImmutableArray1[Unit](array) { | |
| protected[this] def elemManifest = ClassManifest.Unit | |
| } | |
| final class StringArray(val str: String) extends ImmutableArray[Char] { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| override protected[this] def newBuilder = (new StringBuilder).mapResult(new StringArray(_)) | |
| def apply(idx: Int) = str(idx) | |
| def length = str.length | |
| override def toArray[B >: Char : ClassManifest]: Array[B] = str.toArray | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scalaz | |
| import scala.collection.IndexedSeq | |
| import reflect.ClassManifest | |
| import collection.{IndexedSeqLike, IndexedSeqOptimized} | |
| import scala.collection.generic._ | |
| import collection.mutable.{ArrayBuffer, ArrayBuilder, Builder} | |
| /** | |
| * An immutable wrapper for arrays | |
| * | |
| * @tparam A type of the elements of the array | |
| */ | |
| abstract class ImmutableArray[+A] extends IndexedSeq[A] /* with IndexedSeqOptimized[A, ImmutableArray[A]] */ { | |
| protected[this] def elemManifest: ClassManifest[A] | |
| override def stringPrefix = "ImmutableArray" | |
| // override def companion = ImmutableArray | |
| } | |
| object ImmutableArray extends GenericCompanion[IndexedSeq] { | |
| def make[A](x: AnyRef): ImmutableArray[A] = { | |
| val y = x match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case x: Array[AnyRef] => new ofRef(x) | |
| case x: String => new StringArray(x) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| /** Gives better type inference than make[A] */ | |
| def fromArray[A](x: Array[A]): ImmutableArray[A] = { | |
| val y = x.asInstanceOf[AnyRef] match { | |
| case null => null | |
| case x: Array[Byte] => new ofByte(x) | |
| case x: Array[Short] => new ofShort(x) | |
| case x: Array[Char] => new ofChar(x) | |
| case x: Array[Int] => new ofInt(x) | |
| case x: Array[Long] => new ofLong(x) | |
| case x: Array[Float] => new ofFloat(x) | |
| case x: Array[Double] => new ofDouble(x) | |
| case x: Array[Boolean] => new ofBoolean(x) | |
| case x: Array[Unit] => new ofUnit(x) | |
| case y: Array[AnyRef] => new ofRef(x.asInstanceOf[Array[AnyRef]]) | |
| } | |
| y.asInstanceOf[ImmutableArray[A]] | |
| } | |
| // override def newBuilder[A]: Builder[A, ImmutableArray[A]] = newBuilder(implicitly[ClassManifest[A]]) | |
| // def newBuilder[A]: Builder[A, ImmutableArray[A]] = (new ArrayBuffer[A]).mapResult(b => fromArray(b.toArray)) | |
| override def newBuilder[A]: Builder[A, scala.collection.IndexedSeq[A]] = new ArrayBuffer[A] | |
| def newBuilder[A](elemManifest: ClassManifest[A]): Builder[A, ImmutableArray[A]] = | |
| ArrayBuilder.make[A]()(elemManifest).mapResult(make(_)) | |
| abstract class ImmutableArray1[+A](array: Array[A]) extends ImmutableArray[A] { | |
| private[this] val arr = array.clone | |
| override def stringPrefix = "ImmutableArray" | |
| override protected[this] def newBuilder = ImmutableArray.newBuilder[A](elemManifest) | |
| def apply(idx: Int) = arr(idx) | |
| def length = arr.length | |
| override def toArray[B >: A : ClassManifest]: Array[B] = arr.clone.asInstanceOf[Array[B]] | |
| override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) { | |
| var l = len | |
| if (arr.length < l) l = arr.length | |
| if (xs.length - start < l) l = xs.length - start max 0 | |
| Array.copy(arr, 0, xs, start, l) | |
| } | |
| } | |
| final class ofRef[+T <: AnyRef](array: Array[T]) extends ImmutableArray1[T](array) { | |
| protected[this] lazy val elemManifest = ClassManifest.classType[T](array.getClass.getComponentType) | |
| } | |
| final class ofByte(array: Array[Byte]) extends ImmutableArray1[Byte](array) { | |
| protected[this] def elemManifest = ClassManifest.Byte | |
| } | |
| final class ofShort(array: Array[Short]) extends ImmutableArray1[Short](array) { | |
| protected[this] def elemManifest = ClassManifest.Short | |
| } | |
| final class ofChar(array: Array[Char]) extends ImmutableArray1[Char](array) { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| } | |
| final class ofInt(array: Array[Int]) extends ImmutableArray1[Int](array) { | |
| protected[this] def elemManifest = ClassManifest.Int | |
| } | |
| final class ofLong(array: Array[Long]) extends ImmutableArray1[Long](array) { | |
| protected[this] def elemManifest = ClassManifest.Long | |
| } | |
| final class ofFloat(array: Array[Float]) extends ImmutableArray1[Float](array) { | |
| protected[this] def elemManifest = ClassManifest.Float | |
| } | |
| final class ofDouble(array: Array[Double]) extends ImmutableArray1[Double](array) { | |
| protected[this] def elemManifest = ClassManifest.Double | |
| } | |
| final class ofBoolean(array: Array[Boolean]) extends ImmutableArray1[Boolean](array) { | |
| protected[this] def elemManifest = ClassManifest.Boolean | |
| } | |
| final class ofUnit(array: Array[Unit]) extends ImmutableArray1[Unit](array) { | |
| protected[this] def elemManifest = ClassManifest.Unit | |
| } | |
| final class StringArray(val str: String) extends ImmutableArray[Char] { | |
| protected[this] def elemManifest = ClassManifest.Char | |
| override protected[this] def newBuilder = (new StringBuilder).mapResult(new StringArray(_)) | |
| def apply(idx: Int) = str(idx) | |
| def length = str.length | |
| override def toArray[B >: Char : ClassManifest]: Array[B] = str.toArray | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* __ *\ | |
| ** ________ ___ / / ___ Scala API ** | |
| ** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** | |
| ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** | |
| ** /____/\___/_/ |_/____/_/ | | ** | |
| ** |/ ** | |
| \* */ | |
| package scala.collection | |
| package mutable | |
| import scala.reflect.ClassManifest | |
| import scala.collection.generic._ | |
| /** | |
| * A class representing `Array[T]`. | |
| * | |
| * @tparam T type of the elements in this wrapped array. | |
| * | |
| * @author Martin Odersky, Stephane Micheloud | |
| * @version 1.0 | |
| * @since 2.8 | |
| * @define Coll WrappedArray | |
| * @define coll wrapped array | |
| * @define orderDependent | |
| * @define orderDependentFold | |
| * @define mayNotTerminateInf | |
| * @define willNotTerminateInf | |
| */ | |
| abstract class WrappedArray[T] extends IndexedSeq[T] with ArrayLike[T, WrappedArray[T]] { | |
| override protected[this] def thisCollection: WrappedArray[T] = this | |
| override protected[this] def toCollection(repr: WrappedArray[T]): WrappedArray[T] = repr | |
| /** The manifest of the element type */ | |
| def elemManifest: ClassManifest[T] | |
| /** The length of the array */ | |
| def length: Int | |
| /** The element at given index */ | |
| def apply(index: Int): T | |
| /** Update element at given index */ | |
| def update(index: Int, elem: T): Unit | |
| /** The underlying array */ | |
| def array: Array[T] | |
| override def toArray[U >: T : ClassManifest]: Array[U] = | |
| if (implicitly[ClassManifest[U]].erasure eq array.getClass.getComponentType) | |
| array.asInstanceOf[Array[U]] | |
| else | |
| super.toArray[U] | |
| override def stringPrefix = "WrappedArray" | |
| /** Clones this object, including the underlying Array. */ | |
| override def clone: WrappedArray[T] = WrappedArray make array.clone() | |
| /** Creates new builder for this collection ==> move to subclasses | |
| */ | |
| override protected[this] def newBuilder: Builder[T, WrappedArray[T]] = | |
| new WrappedArrayBuilder[T](elemManifest) | |
| } | |
| /** A companion object used to create instances of `WrappedArray`. | |
| */ | |
| object WrappedArray { | |
| def make[T](x: AnyRef): WrappedArray[T] = x match { | |
| case x: Array[AnyRef] => wrapRefArray[AnyRef](x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Int] => wrapIntArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Double] => wrapDoubleArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Long] => wrapLongArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Float] => wrapFloatArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Char] => wrapCharArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Byte] => wrapByteArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Short] => wrapShortArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Boolean] => wrapBooleanArray(x).asInstanceOf[WrappedArray[T]] | |
| case x: Array[Unit] => wrapUnitArray(x).asInstanceOf[WrappedArray[T]] | |
| } | |
| implicit def canBuildFrom[T](implicit m: ClassManifest[T]): CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] = | |
| new CanBuildFrom[WrappedArray[_], T, WrappedArray[T]] { | |
| def apply(from: WrappedArray[_]): Builder[T, WrappedArray[T]] = | |
| ArrayBuilder.make[T]()(m) mapResult WrappedArray.make[T] | |
| def apply: Builder[T, WrappedArray[T]] = | |
| ArrayBuilder.make[T]()(m) mapResult WrappedArray.make[T] | |
| } | |
| def newBuilder[A]: Builder[A, IndexedSeq[A]] = new ArrayBuffer | |
| @serializable | |
| final class ofRef[T <: AnyRef](val array: Array[T]) extends WrappedArray[T] { | |
| lazy val elemManifest = ClassManifest.classType[T](array.getClass.getComponentType) | |
| def length: Int = array.length | |
| def apply(index: Int): T = array(index).asInstanceOf[T] | |
| def update(index: Int, elem: T) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofByte(val array: Array[Byte]) extends WrappedArray[Byte] { | |
| def elemManifest = ClassManifest.Byte | |
| def length: Int = array.length | |
| def apply(index: Int): Byte = array(index) | |
| def update(index: Int, elem: Byte) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofShort(val array: Array[Short]) extends WrappedArray[Short] { | |
| def elemManifest = ClassManifest.Short | |
| def length: Int = array.length | |
| def apply(index: Int): Short = array(index) | |
| def update(index: Int, elem: Short) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofChar(val array: Array[Char]) extends WrappedArray[Char] { | |
| def elemManifest = ClassManifest.Char | |
| def length: Int = array.length | |
| def apply(index: Int): Char = array(index) | |
| def update(index: Int, elem: Char) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofInt(val array: Array[Int]) extends WrappedArray[Int] { | |
| def elemManifest = ClassManifest.Int | |
| def length: Int = array.length | |
| def apply(index: Int): Int = array(index) | |
| def update(index: Int, elem: Int) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofLong(val array: Array[Long]) extends WrappedArray[Long] { | |
| def elemManifest = ClassManifest.Long | |
| def length: Int = array.length | |
| def apply(index: Int): Long = array(index) | |
| def update(index: Int, elem: Long) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofFloat(val array: Array[Float]) extends WrappedArray[Float] { | |
| def elemManifest = ClassManifest.Float | |
| def length: Int = array.length | |
| def apply(index: Int): Float = array(index) | |
| def update(index: Int, elem: Float) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofDouble(val array: Array[Double]) extends WrappedArray[Double] { | |
| def elemManifest = ClassManifest.Double | |
| def length: Int = array.length | |
| def apply(index: Int): Double = array(index) | |
| def update(index: Int, elem: Double) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofBoolean(val array: Array[Boolean]) extends WrappedArray[Boolean] { | |
| def elemManifest = ClassManifest.Boolean | |
| def length: Int = array.length | |
| def apply(index: Int): Boolean = array(index) | |
| def update(index: Int, elem: Boolean) { array(index) = elem } | |
| } | |
| @serializable | |
| final class ofUnit(val array: Array[Unit]) extends WrappedArray[Unit] { | |
| def elemManifest = ClassManifest.Unit | |
| def length: Int = array.length | |
| def apply(index: Int): Unit = array(index) | |
| def update(index: Int, elem: Unit) { array(index) = elem } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment