final class SparseArray[V] extends ArrayLike[V] with Storage[V] with Serializable
A SparseArray is a sparse representation of an array using a two-array binary-search approach. There are two arrays: index and data, which together are pairs (i, v) of indices into the array and the value at that position.
The default value is assumed to be null for AnyRef, and 0 for AnyVal types.
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- SparseArray
- Serializable
- Storage
- ArrayLike
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
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
activeSize: Int
How many elements are stored in terms of space.
How many elements are stored in terms of space. In HashVectors, activeSize is the number of non-zero elements, while iterableSize is the number of buckets currently allocated. (activeSize <= iterableSize in general, activeSize == iterableSize for everything except hashing implementations.)
- Definition Classes
- SparseArray → Storage → ArrayLike
-
def
allVisitableIndicesActive: Boolean
Only gives true if isActive would return true for all i.
Only gives true if isActive would return true for all i. (May be false anyway)
- Definition Classes
- SparseArray → Storage
-
final
def
apply(i: Int): V
- Definition Classes
- SparseArray → ArrayLike
- Annotations
- @inline()
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate() @throws( ... )
-
def
compact(): Unit
Compacts the array by removing all stored default values.
- def concatenate(that: SparseArray[V])(implicit man: ClassTag[V]): SparseArray[V]
- def contains(i: Int): Boolean
-
var
data: Array[V]
Returns the actual flat array of elements used.
Returns the actual flat array of elements used.
- Definition Classes
- SparseArray → Storage
- val default: V
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(o: Any): Boolean
- Definition Classes
- SparseArray → AnyRef → Any
-
def
filter(f: (V) ⇒ Boolean): SparseArray[V]
Filter's the array by removing all values for which f is false.
-
final
def
findOffset(i: Int): Int
Returns the offset into index and data for the requested vector index.
Returns the offset into index and data for the requested vector index. If the requested index is not found, the value is negative and can be converted into an insertion point with ~rv.
- Attributes
- protected
-
def
foreach[U](f: (V) ⇒ U): Unit
Only iterates "active" elements.
Only iterates "active" elements. I'm not sure how I feel about this behavior, since it's inconsistent with the rest of Breeze. I will think on it.
- Definition Classes
- ArrayLike
- def get(i: Int): Option[V]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getOrElse(i: Int, value: ⇒ V): V
- def getOrElseUpdate(i: Int, value: ⇒ V): V
-
def
hashCode(): Int
- Definition Classes
- SparseArray → AnyRef → Any
- var index: Array[Int]
-
final
def
indexAt(i: Int): Int
Gives the logical index from the physical index.
Gives the logical index from the physical index.
- Definition Classes
- SparseArray → Storage
-
def
isActive(i: Int): Boolean
Some storages (namely HashStorage) won't have active indices packed.
Some storages (namely HashStorage) won't have active indices packed. This lets you know if the bin is actively in use.
- i
index into index/data arrays
- Definition Classes
- SparseArray → Storage
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
iterableSize: Int
How many elements must be iterated over using valueAt/indexAt.
How many elements must be iterated over using valueAt/indexAt. In HashVectors, activeSize is the number of non-zero elements, while iterableSize is the number of buckets currently allocated. (activeSize <= iterableSize in general, activeSize == iterableSize for everything except hashing implementations.)
- Definition Classes
- Storage
-
def
iterator: Iterator[(Int, V)]
Only iterates "active" elements
Only iterates "active" elements
- Definition Classes
- ArrayLike
-
def
keysIterator: Iterator[Int]
Only iterates "active" keys
Only iterates "active" keys
- Definition Classes
- SparseArray → ArrayLike
-
def
length: Int
- Definition Classes
- ArrayLike
-
def
map[B](f: (V) ⇒ B)(implicit arg0: ClassTag[B], arg1: Zero[B]): SparseArray[B]
Maps all values.
Maps all values. If f(this.default) is not equal to the new default value, the result may be an efficiently dense (or almost dense) paired array.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
quickCompact(): Unit
Like compact, but doesn't look for defaultValues that can be removed.
- def reserve(nnz: Int): Unit
-
val
size: Int
How many elements are logically stored here.
How many elements are logically stored here. This may be <= activeSize.
- Definition Classes
- SparseArray → Storage → ArrayLike
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toArray[U >: V](implicit arg0: ClassTag[U]): Array[U]
- Definition Classes
- ArrayLike
-
def
toIndexedSeq: List[V]
- Definition Classes
- ArrayLike
-
def
toList: List[V]
- Definition Classes
- ArrayLike
-
def
toMap: Map[Int, V]
- Definition Classes
- ArrayLike
-
def
toString(): String
- Definition Classes
- SparseArray → AnyRef → Any
-
final
def
update(i: Int, value: V): Unit
Sets the given value at the given index if the value is not equal to the current default.
Sets the given value at the given index if the value is not equal to the current default. The data and index arrays will be grown to support the insertion if necessary. The growth schedule doubles the amount of allocated memory at each allocation request up until the sparse array contains 1024 values, at which point the growth is additive: an additional n * 1024 spaces will be allocated for n in 1,2,4,8,16. The largest amount of space added to this vector will be an additional 16*1024*(sizeof(Elem)+4), which is 196608 bytes at a time for a SparseVector[Double], although more space is needed temporarily while moving to the new arrays.
- Definition Classes
- SparseArray → ArrayLike
- Annotations
- @inline()
- def use(index: Array[Int], data: Array[V], used: Int): Unit
-
final
def
valueAt(i: Int): V
same as data(i).
same as data(i). Gives the value at the underlying offset.
- i
index into the data array
- Definition Classes
- SparseArray → Storage
-
def
valuesIterator: Iterator[V]
Only iterates "active" elements
Only iterates "active" elements
- Definition Classes
- SparseArray → ArrayLike
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )