final class ImmArray[+A] extends AnyRef
Simple immutable array. The intention is that all the operations have the "obvious" operational behavior (like Vector in haskell).
Functions that slice the ImmArray
(including head
, tail
, etc) are all constant time --
they keep referring to the same underlying array.
Note that we _very intentionally_ do _not_ make this an instance of any sorts of Seq
, since
using Seq
encourages patterns where the performance of what you're doing is totally
unclear. Use toSeq
if you want a Seq
, and think about what that means.
- Self Type
- ImmArray[A]
- Alphabetic
- By Inheritance
- ImmArray
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(idx: Int): A
O(1), crashes on out of bounds
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def canEqual(that: Any): Boolean
O(1)
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- def collect[B](f: PartialFunction[A, B]): ImmArray[B]
O(n)
- def copyToArray[B >: A](xs: Array[B]): Int
O(n)
- def copyToArray[B >: A](dst: Array[B], dstStart: Int, dstLen: Int): Int
O(n)
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(that: Any): Boolean
O(n)
O(n)
- Definition Classes
- ImmArray → AnyRef → Any
- def filter(f: (A) => Boolean): ImmArray[A]
O(n)
- def find(f: (A) => Boolean): Option[A]
O(n)
- def foldLeft[B](z: B)(f: (B, A) => B): B
O(n)
- def foldRight[B](z: B)(f: (A, B) => B): B
O(n)
- def foreach(f: (A) => Unit): Unit
O(n)
- def get(idx: Int): Option[A]
O(1)
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- ImmArray → AnyRef → Any
- def head: A
O(1), crashes on empty list
- def indexWhere(p: (A) => Boolean): Int
O(n)
- def indices: Range
O(1)
- def init: ImmArray[A]
O(1), crashes on empty list
- def isEmpty: Boolean
O(1)
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: Iterator[A]
- def last: A
O(1), crashes on empty list
- val length: Int
- def map[B](f: (A) => B): ImmArray[B]
O(n)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def nonEmpty: Boolean
O(1)
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def relaxedSlice(from0: Int, until0: Int): ImmArray[A]
O(1), like
strictSlice
, but does not crash on out of bounds errors -- follows the same semantics as Seq's slice. - def reverse: ImmArray[A]
O(n)
- def reverseIterator: Iterator[A]
- def slowAppend[B >: A](other: ImmArray[B]): ImmArray[B]
O(n+m)
O(n+m)
If you find using this a lot, consider using another data structure (maybe FrontQueue or BackQueue), since to append ImmArray we must copy both of them.
- def slowCons[B >: A](el: B): ImmArray[B]
O(n)
O(n)
If you find yourself using this a lot, consider using another data structure, since to cons an ImmArray we must copy it.
- def slowSnoc[B >: A](el: B): ImmArray[B]
O(n)
O(n)
If you find yourself using this a lot, consider using another data structure, since to snoc an ImmArray we must copy it.
- def strictSlice(from: Int, until: Int): ImmArray[A]
O(1)
O(1)
Returns all the elements at indices
ix
wherefrom <= ix < until
.Crashes if: *
from < 0 || from >= length
*until < 0 || until > length
Note that this crashing behavior is _not_ consistent with Seq's behavior of not crashing but rather returning an empty array. If you want Seq's behavior, use
relaxedSlice
. - final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tail: ImmArray[A]
O(1), crashes on empty list
- def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]
O(n)
- def toFrontStack: FrontStack[A]
- def toIndexedSeq: ImmArraySeq[A]
O(1).
O(1).
Note: very important that this is a
scala.collection.immutable.IndexedSeq
, and not a possibly mutablescala.collection.IndexedSeq
, otherwise we could return thearray
as is and people would be able to break the originalImmArray
. - def toList: List[A]
O(n)
- def toSeq: ImmArraySeq[A]
O(1)
O(1)
Note: very important that this is a
scala.collection.immutable.IndexedSeq
, and not a possibly mutablescala.collection.IndexedSeq
, otherwise we could return thearray
as is and people would be able to break the originalImmArray
. - def toString(): String
O(n)
O(n)
- Definition Classes
- ImmArray → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def zip[B](that: ImmArray[B]): ImmArray[(A, B)]
O(min(n, m))
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated