public class SparseBackingBuffer extends Object implements MatrixBackingBuffer, Cloneable
HashMap
as internal datastructure.
Only values that differ from the defaultValue
(can be set via SparseBackingBuffer(float)
)
are actually stored.
If you intend to place values in most possible matrix positions, this is not a suitable implementation.Constructor and Description |
---|
SparseBackingBuffer()
Sparse backing buffer with default value
0f . |
SparseBackingBuffer(float defaultValue)
Creates a sparse backing buffer with the given default value.
|
Modifier and Type | Method and Description |
---|---|
void |
allocate(int size)
Allocates the internal data structure.
|
Object |
clone() |
float |
get(int index)
Reads a value.
|
boolean |
isAllocated()
Indicates whether the internal data structure is already allocated.
|
void |
set(int index,
float value)
Write a value.
|
public SparseBackingBuffer(float defaultValue)
defaultValue
- default valuepublic SparseBackingBuffer()
0f
.public void allocate(int size)
MatrixBackingBuffer
allocate
in interface MatrixBackingBuffer
size
- sizepublic boolean isAllocated()
MatrixBackingBuffer
isAllocated
in interface MatrixBackingBuffer
public void set(int index, float value)
MatrixBackingBuffer
set
in interface MatrixBackingBuffer
index
- indexvalue
- valuepublic float get(int index)
MatrixBackingBuffer
get
in interface MatrixBackingBuffer
index
- indexpublic Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Copyright © 2011–2020 tagtraum industries incorporated. All rights reserved.