Class/Object

software.uncharted.salt.core.util

SparseArray

Related Docs: object SparseArray | package util

Permalink

class SparseArray[T] extends Serializable

An integer-indexed sparse array implementation, currently based on HashMap.

Specialized for storing Ints, Longs and Doubles

Automatically materializes into a dense array when the number of non-default values stored exceeds some threshold.

Note that this is not a standard scala sequence. Use the .seq method to obtain an equivalent that is, if needed.

Probably not thread-safe due to lack of locking on materialization.

TODO: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReadWriteLock.html

T

the type of value being stored in the SparseArray

Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SparseArray
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SparseArray(_length: Int, _default: ⇒ T, _threshold: Float = 1/3F)(implicit arg0: ClassTag[T])

    Permalink

    _length

    The (fixed) length of the array

    _default

    The default value used for elements without a specifically set value.

    _threshold

    The proportion of elements with non-default values beyond which the array will be materialized

Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply(index: Int): T

    Permalink

    Getter for the element at the given index

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def default(): T

    Permalink

    The default value of the sparse array

  8. def density(): Float

    Permalink

    The density - or the proportion of elements with non-default values - of this SparseArray

  9. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. def head: T

    Permalink

    Shorthand accessor for the first element of the array

    Shorthand accessor for the first element of the array

    returns

    The head element

  15. def indices: Range

    Permalink

    The range of indices of the sparse array

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. def length(): Int

    Permalink

    The (fixed) length of the sparse array

  18. def map[U](fcn: (T) ⇒ U)(implicit arg0: ClassTag[U]): SparseArray[U]

    Permalink

    Transform this SparseArray according to the input function

    Transform this SparseArray according to the input function

    Note that side-effects (such as a side total) are not guaranteed correct in SparseArrays - the transformation function will not be run on defaulted entries.

    U

    The output value type

    fcn

    The value transformation function

    returns

    A new SparseArray, with the values of this array transformed as specified

  19. def mapWithIndex[U](fcn: (T, Int) ⇒ U)(implicit arg0: ClassTag[U]): SparseArray[U]

    Permalink

    Transform this SparseArray according to the input function.

    Transform this SparseArray according to the input function.

    Unlike map, the input function here is given the index of the element.

    For the default value, it is given an index of -1.

    U

    The output value type

    fcn

    The value transformation function

    returns

    A new SparseArray, with the values of this array transformed as specified

  20. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  23. def seq: Seq[T]

    Permalink

    Transform this SparseArray into a normal scala Seq.

    Transform this SparseArray into a normal scala Seq. This returns a materialized form of the SparseArray, but does not materialize the SparseArray itself.

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. def update(index: Int, value: T): Unit

    Permalink

    Setter for the element at the given index

  27. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped