Trait/Object

xerial.larray

LArray

Related Docs: object LArray | package larray

Permalink

trait LArray[A] extends LSeq[A] with WritableByteChannel

LArray is a mutable large array.

The differences from the standard Array[A] are:

Usage

import xerial.larray._

// Create a new LArray of Int type
val l = LArray.of[Int](5)

// Create an LArray with initial values
val ll = LArray(3, 5, 9, 10)

// Set elements
for(i <- 0 until l.size.toInt)
  l(i) = i

// Read elements
val e0 = l(0)
val e1 = l(1)

// Print the elements
println(l.mkString(", ")) // 0, 1, 2, 3, 4

// Traverse the elements with their indexes
for((e, i) <- l.zipWithIndex)
  println(s"l($i) = $e") // l(0) = 0, l(1) = 1, ...

// Manipulate LArray
val l2 = l.map(_ * 10) // LArray(0, 10, 20, 30, 40)
val f = l.filter(_ % 2 == 0) // LArray(0, 2, 4)
val s = l.slice(2) // LArray(2, 3, 4)
l.foreach(println(_))

// Build LArray
val b = LArray.newBuilder[Int]
for(i <- 0 until (10, step=3))
  b += i
val lb = b.result // LArray(0, 3, 6, 9)

// Convert to Scala Array
val arr = l.toArray
println(arr.mkString(", ")) // 0, 1, 2, 3, 4

// Convert Scala Array to LArray
val arr2 = Array(1, 3, 5)
val la = arr2.toLArray

// Save to a file
import java.io.File
val file = l.saveTo(new File("target/larray.tmp"))
// Load from a file
val l3 = LArray.loadFrom[Int](file) // LArray(0, 1, 2, 3, 4)

// Initialize the array
l.clear()
println(l.mkString(", ")) // 0, 0, 0, 0, 0

// Release the memory contents.
l.free
l3.free

// You can omit calling free, because GC collects unused LArrays
A

element type

Source
LArray.scala
Linear Supertypes
WritableByteChannel, Channel, Closeable, AutoCloseable, LSeq[A], LIterable[A], AnyRef, Any
Known Subclasses
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. LArray
  2. WritableByteChannel
  3. Channel
  4. Closeable
  5. AutoCloseable
  6. LSeq
  7. LIterable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Repr = LArray[A]

    Permalink
    Definition Classes
    LIterable
  2. class SlidingIterator extends AbstractLIterator[LSeq.Repr]

    Permalink
    Definition Classes
    LIterable

Abstract Value Members

  1. abstract def address: Long

    Permalink

    Raw-memory address of this array

    Raw-memory address of this array

    Definition Classes
    LSeq
    Annotations
    @inline()
  2. abstract def apply(i: Long): A

    Permalink

    Retrieve an element at the given index.

    Retrieve an element at the given index. LArray does not perform boundary checks for optimizing the performance, so reading the indexes out of bounds might cause JVM crash.

    i

    index

    returns

    the element value

    Definition Classes
    LSeq
    Annotations
    @inline()
  3. abstract def clear(): Unit

    Permalink

    Clear the contents of the array.

    Clear the contents of the array. It simply fills the array with zero bytes.

  4. abstract def copyTo[B](srcOffset: Long, dst: RawByteArray[B], dstOffset: Long, blen: Long): Unit

    Permalink

    Copy the contents of this sequence into the target LByteArray

    Copy the contents of this sequence into the target LByteArray

    blen

    the byte length to copy

    Definition Classes
    LSeq
  5. abstract def copyTo(dst: LByteArray, dstOffset: Long): Unit

    Permalink

    Copy the contents of this LSeq[A] into the target LByteArray

    Copy the contents of this LSeq[A] into the target LByteArray

    Definition Classes
    LSeq
  6. abstract def free: Unit

    Permalink

    Release the memory of LArray.

    Release the memory of LArray. After calling this method, the results of calling the other methods becomes undefined or might cause JVM crash.

  7. abstract def newBuilder: LBuilder[A, Repr]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    LIterable
  8. abstract def size: Long

    Permalink

    Element size of this array

    Element size of this array

    returns

    size of this array

    Definition Classes
    LSeq
  9. abstract def update(i: Long, v: A): A

    Permalink

    Update an element

    Update an element

    i

    index to be updated

    v

    value to set

    returns

    the value

    Annotations
    @inline()
  10. abstract def view(from: Long, to: Long): LArrayView[A]

    Permalink

    Create a shallow copy (view) of LArray

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++(other: LSeq[A]): Repr

    Permalink

    Create a new array that concatenates two arrays

    Create a new array that concatenates two arrays

    Definition Classes
    LIterable
  4. def +:(elem: A): Repr

    Permalink

    Copy of thie array with an element prepended.

    Copy of thie array with an element prepended.

    elem

    the prepended element.

    returns

    a new array consisting ofall elements of this array preceded by the new elem.

    Definition Classes
    LIterable
  5. def /:[B](z: B)(op: (B, A) ⇒ B): B

    Permalink

    fold left

    fold left

    B

    the result type of the binary operator

    z

    the start value

    op

    the binary operator

    returns

    the result of inserting op between consecutive elements of this array, going left to right with the start value z on the left:

    op(...op(op(z, x1), x2), ..., xn)))
    Definition Classes
    LIterable
  6. def :+(elem: A): Repr

    Permalink

    Copy of this array with an element appended.

    Copy of this array with an element appended.

    elem

    the appended element

    returns

    a new array consisting of all elements of this array follwed by the new elem

    Definition Classes
    LIterable
  7. def :\[B](z: B)(op: (A, B) ⇒ B): B

    Permalink

    fold right

    fold right

    B

    the result type of the binary operator

    z

    the start value

    op

    the binary operator

    returns

    the result of inserting op between consecutive elements of this array, going right to left with the start value z on the right:

    op(x1, op(x2, ..., op(xn, z)...))
    Definition Classes
    LIterable
  8. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder

    Permalink
    Definition Classes
    LIterable
  10. def aggregate[B](z: B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B

    Permalink
    Definition Classes
    LIterable
  11. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  12. def byteLength: Long

    Permalink

    Byte length of this array.

    Byte length of this array.

    Definition Classes
    LSeq
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def close(): Unit

    Permalink
    Definition Classes
    LArray → Channel → Closeable → AutoCloseable
  15. def collect[B](pf: PartialFunction[A, B]): LIterator[B]

    Permalink

    Builds a new collection by applying a partial function to all elments of this array on which the function is defined.

    Builds a new collection by applying a partial function to all elments of this array on which the function is defined.

    Definition Classes
    LIterable
  16. def collectFirst[B](pf: PartialFunction[A, B]): Option[B]

    Permalink

    Finds the first element of this array on which the given partial function is defined, and applies the partial function to it.

    Finds the first element of this array on which the given partial function is defined, and applies the partial function to it.

    B

    return type

    pf

    partial function

    returns

    an option value containing pf applied to the first value for which the function is defined, or None if not exists.

    Definition Classes
    LIterable
  17. def concat(other: LSeq[A]): Repr

    Permalink

    Create a new array that concatenates two arrays

    Create a new array that concatenates two arrays

    Definition Classes
    LIterable
  18. def contains(elem: A): Boolean

    Permalink
    Definition Classes
    LIterable
  19. def copyToArray[B >: A](xs: LArray[B], start: Long, len: Long): Unit

    Permalink
    Definition Classes
    LIterable
  20. def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit

    Permalink
    Definition Classes
    LIterable
  21. def drop(n: Long): Repr

    Permalink
    Definition Classes
    LIterable
  22. def dropWhile(p: (A) ⇒ Boolean): Repr

    Permalink
    Definition Classes
    LIterable
  23. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  24. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  25. def exists(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    LIterable
  26. def filter(pred: (A) ⇒ Boolean): LIterator[A]

    Permalink
    Definition Classes
    LIterable
  27. def filterNot(pred: (A) ⇒ Boolean): LIterator[A]

    Permalink
    Definition Classes
    LIterable
  28. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. def find(p: (A) ⇒ Boolean): Option[A]

    Permalink
    Definition Classes
    LIterable
  30. def flatMap[B](f: (A) ⇒ LIterator[B]): LIterator[B]

    Permalink
    Definition Classes
    LIterable
  31. def fold[A1 >: A](z: A1)(op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    LIterable
  32. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    LIterable
  33. def foldRight[B](z: B)(op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    LIterable
  34. def forall(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    LIterable
  35. def foreach[U](f: (A) ⇒ U): Unit

    Permalink
    Definition Classes
    LIterable
  36. def getByte(offset: Long): Byte

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  37. def getChar(offset: Long): Char

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  38. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  39. def getDouble(offset: Long): Double

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  40. def getFloat(offset: Long): Float

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  41. def getInt(offset: Long): Int

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  42. def getLong(offset: Long): Long

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  43. def getShort(offset: Long): Short

    Permalink
    Definition Classes
    LSeq
    Annotations
    @inline()
  44. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  45. def head: A

    Permalink
    Definition Classes
    LIterable
  46. def indexOf[B >: A](elem: B): Long

    Permalink
    Definition Classes
    LIterable
  47. def indexWhere(p: (A) ⇒ Boolean, from: Long): Long

    Permalink
    Definition Classes
    LIterable
  48. def init: Repr

    Permalink
    Definition Classes
    LIterable
  49. def isEmpty: Boolean

    Permalink

    Tests whether this sequence is empty

    Tests whether this sequence is empty

    Definition Classes
    LIterable
  50. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  51. def isOpen(): Boolean

    Permalink
    Definition Classes
    LArray → Channel
  52. def iterator: LIterator[A]

    Permalink

    Creates a new iterator over all elements contained in this collection

    Creates a new iterator over all elements contained in this collection

    Definition Classes
    LIterable
  53. def ji: Iterable[A]

    Permalink

    Provides the Iterable interface for Java

    Provides the Iterable interface for Java

    Definition Classes
    LIterable
  54. def last: A

    Permalink
    Definition Classes
    LIterable
  55. def lastIndexWhere(p: (A) ⇒ Boolean, end: Int): Int

    Permalink
    Definition Classes
    LIterable
  56. def length: Long

    Permalink
    Definition Classes
    LIterable
  57. def map[B](f: (A) ⇒ B): LIterator[B]

    Permalink
    Definition Classes
    LIterable
  58. def mkString: String

    Permalink
    Definition Classes
    LIterable
  59. def mkString(sep: String): String

    Permalink
    Definition Classes
    LIterable
  60. def mkString(start: String, sep: String, end: String): String

    Permalink
    Definition Classes
    LIterable
  61. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  62. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  63. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  64. def partition(p: (A) ⇒ Boolean): (LIterator[A], LIterator[A])

    Permalink
    Definition Classes
    LIterable
  65. def prefixLength(p: (A) ⇒ Boolean): Long

    Permalink
    Definition Classes
    LIterable
  66. def putByte(offset: Long, v: Byte): Byte

    Permalink
    Annotations
    @inline()
  67. def putChar(offset: Long, v: Char): Char

    Permalink
    Annotations
    @inline()
  68. def putDouble(offset: Long, v: Double): Double

    Permalink
    Annotations
    @inline()
  69. def putFloat(offset: Long, v: Float): Float

    Permalink
    Annotations
    @inline()
  70. def putInt(offset: Long, v: Int): Int

    Permalink
    Annotations
    @inline()
  71. def putLong(offset: Long, v: Long): Long

    Permalink
    Annotations
    @inline()
  72. def putShort(offset: Long, v: Short): Short

    Permalink
    Annotations
    @inline()
  73. def reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    LIterable
  74. def reduceLeft[B >: A](op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    LIterable
  75. def reduceLeftOption[B >: A](op: (B, A) ⇒ B): Option[B]

    Permalink
    Definition Classes
    LIterable
  76. def reduceOption[A1 >: A](op: (A1, A1) ⇒ A1): Option[A1]

    Permalink
    Definition Classes
    LIterable
  77. def reduceRight[B >: A](op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    LIterable
  78. def reduceRightOption[B >: A](op: (A, B) ⇒ B): Option[B]

    Permalink
    Definition Classes
    LIterable
  79. def release: Unit

    Permalink

    Release the memory of LArray.

    Release the memory of LArray. After calling this mehtod, thr results of calling the other methods becomes undefined or might cause JVM crash.

  80. def reverse[A]: Repr

    Permalink
    Definition Classes
    LIterable
  81. def reverseIterator: LIterator[A]

    Permalink
    Definition Classes
    LIterable
  82. def sameElements[B >: A](that: LIterable[B]): Boolean

    Permalink
    Definition Classes
    LIterable
  83. def saveTo(f: File): File

    Permalink

    Save to a file.

    Save to a file.

    Definition Classes
    LSeq
  84. def scanLeft[B](z: B)(op: (B, A) ⇒ B): LIterator[B]

    Permalink
    Definition Classes
    LIterable
  85. def segmentLength(p: (A) ⇒ Boolean, from: Long): Long

    Permalink
    Definition Classes
    LIterable
  86. def slice(from: Long, until: Long): LArray[A]

    Permalink
    Definition Classes
    LIterable
  87. def slice(from: Long): LArray[A]

    Permalink
    Definition Classes
    LIterable
  88. def sliding(size: Long, step: Long): LIterator[Repr]

    Permalink

    Groups elemnts in fixed size blocks by passing a 'sliding window' over them.

    Groups elemnts in fixed size blocks by passing a 'sliding window' over them.

    size

    the number of elements per group

    step

    the distance between the first elements of successive groups

    returns

    An itertor producing group of elements.

    Definition Classes
    LIterable
  89. def sliding(size: Int): LIterator[Repr]

    Permalink

    Groups elements in fixed size blocks by passing a 'sliding window' over them

    Groups elements in fixed size blocks by passing a 'sliding window' over them

    size

    the number of elements per group

    returns

    An iterator producing group of elements.

    Definition Classes
    LIterable
  90. def span(p: (A) ⇒ Boolean): (Repr, Repr)

    Permalink
    Definition Classes
    LIterable
  91. def splitAt(n: Long): (Repr, Repr)

    Permalink
    Definition Classes
    LIterable
  92. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  93. def tail: LArray[A]

    Permalink
    Definition Classes
    LIterable
  94. def take(n: Long): Repr

    Permalink
    Definition Classes
    LIterable
  95. def takeRight(n: Long): Repr

    Permalink
    Definition Classes
    LIterable
  96. def takeWhile(p: (A) ⇒ Boolean): Repr

    Permalink
    Definition Classes
    LIterable
  97. def toArray[A1 >: A](implicit arg0: ClassTag[A1]): Array[A1]

    Permalink

    Creates a copy of this array in the form of the standard Scala Array

    Creates a copy of this array in the form of the standard Scala Array

    Definition Classes
    LIterable
  98. def toDirectByteBuffer: Array[ByteBuffer]

    Permalink

    Create a sequence of DirectByteBuffer that projects LArray contents

    Create a sequence of DirectByteBuffer that projects LArray contents

    returns

    sequence of java.nio.ByteBuffer

    Definition Classes
    LSeq
  99. def toIterator: LIterator[A]

    Permalink
    Definition Classes
    LIterable
  100. def toLSeq: LSeq[A]

    Permalink

    Wraps with immutable interface

  101. def toString(): String

    Permalink
    Definition Classes
    LArray → AnyRef → Any
  102. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  103. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  104. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  105. def withFilter(p: (A) ⇒ Boolean): LIterator[A]

    Permalink
    Definition Classes
    LIterable
  106. def write(src: ByteBuffer): Int

    Permalink

    Write the contents of ByteBuffer to this array.

    Write the contents of ByteBuffer to this array. This method increments the internal cursor.

    Definition Classes
    LArray → WritableByteChannel
  107. def zip[B](that: LIterable[B]): LIterator[(A, B)]

    Permalink
    Definition Classes
    LIterable
  108. def zipAll[B, A1 >: A, B1 >: B](that: LIterable[B], thisElem: A1, thatElem: B1): LIterator[(A1, B1)]

    Permalink
    Definition Classes
    LIterable
  109. def zipWithIndex: LIterator[(A, Long)]

    Permalink
    Definition Classes
    LIterable

Inherited from WritableByteChannel

Inherited from Channel

Inherited from Closeable

Inherited from AutoCloseable

Inherited from LSeq[A]

Inherited from LIterable[A]

Inherited from AnyRef

Inherited from Any

Ungrouped