public abstract class Indexer extends Object implements AutoCloseable
Subclasses have create()
factory methods for arrays, buffers, and pointers.
The latter ones feature a direct
argument that, when set to false
,
instructs the method to create a large enough array, fill its content with the data
from the pointer, and return an array-backed indexer, with the release()
method overridden to write back changes to the pointer. This doubles the memory
usage, but is the only way to get acceptable performance on some implementations,
such as Android. When direct == true
, the raw memory interface (supporting
long indexing) is used if available, and if not a buffer-backed indexer is returned.
Raw
Modifier and Type | Field and Description |
---|---|
protected Index |
index
The Index to be used for
index(long...) . |
protected Indexable |
indexable
The associated (optional)
Indexable . |
protected long[] |
sizes
Deprecated.
|
protected long[] |
strides
Deprecated.
|
Modifier | Constructor and Description |
---|---|
protected |
Indexer(Index index)
Constructor to set the
index . |
protected |
Indexer(long[] sizes,
long[] strides)
Calls
Indexer(Index.create(sizes, strides)) . |
Modifier and Type | Method and Description |
---|---|
Object |
array()
Returns the backing array, or
null if none |
Buffer |
buffer()
Returns the backing buffer, or
null if none |
long |
channels()
Deprecated.
|
protected static long |
checkIndex(long i,
long size) |
void |
close()
Calls
release() . |
long |
cols()
Deprecated.
|
abstract double |
getDouble(long... indices)
Calls
get(int...indices) and returns the value as a double. |
long |
height()
Deprecated.
|
long |
index(long... indices)
Returns
index.index(indices) . |
long |
index(long i)
Returns
index.index(i) . |
long |
index(long i,
long j)
Returns
index.index(i, j) . |
long |
index(long i,
long j,
long k)
Returns
index.index(i, j, k) . |
Indexable |
indexable()
Returns
indexable . |
Indexer |
indexable(Indexable indexable)
Sets
indexable and returns this. |
Pointer |
pointer()
Returns the backing pointer, or
null if none |
abstract Indexer |
putDouble(long[] indices,
double value)
Casts value to primitive type and calls
put(long[] indices, <type> value) . |
int |
rank()
Returns
index.rank() . |
abstract <I extends Indexer> |
reindex(Index index)
Returns a new Indexer using the same data, but with a different Index.
|
abstract void |
release()
Makes sure changes are reflected onto the backing memory and clears any references.
|
long |
rows()
Deprecated.
|
long |
size(int i)
Returns
index.size(i) . |
long[] |
sizes()
Returns
index.sizes() . |
long |
stride(int i)
Deprecated.
|
long[] |
strides()
Deprecated.
|
static long[] |
strides(long... sizes)
Deprecated.
|
String |
toString() |
long |
width()
Deprecated.
|
@Deprecated protected long[] sizes
Index.sizes
.@Deprecated protected long[] strides
StrideIndex.strides
.protected final Index index
index(long...)
.protected Indexer(long[] sizes, long[] strides)
Indexer(Index.create(sizes, strides))
.public void close()
release()
.close
in interface AutoCloseable
public int rank()
index.rank()
.public long[] sizes()
index.sizes()
.@Deprecated public long[] strides()
strides
or null
if there are no strides.public long size(int i)
index.size(i)
.@Deprecated public long stride(int i)
strides[i]
or -1
if there are no strides.@Deprecated public long rows()
sizes.length > 0 && sizes.length < 4 ? sizes[0] : -1
.@Deprecated public long cols()
sizes.length > 1 && sizes.length < 4 ? sizes[1] : -1
.@Deprecated public long width()
sizes.length > 1 && sizes.length < 4 ? sizes[1] : -1
.@Deprecated public long height()
sizes.length > 0 && sizes.length < 4 ? sizes[0] : -1
.@Deprecated public long channels()
sizes.length > 2 && sizes.length < 4 ? sizes[2] : -1
.protected static final long checkIndex(long i, long size)
@Deprecated public static long[] strides(long... sizes)
public long index(long i)
index.index(i)
.public long index(long i, long j)
index.index(i, j)
.public long index(long i, long j, long k)
index.index(i, j, k)
.public long index(long... indices)
index.index(indices)
.public Object array()
null
if nonepublic Buffer buffer()
null
if nonepublic Pointer pointer()
null
if nonepublic abstract void release()
public abstract double getDouble(long... indices)
get(int...indices)
and returns the value as a double.public abstract Indexer putDouble(long[] indices, double value)
put(long[] indices, <type> value)
.public abstract <I extends Indexer> I reindex(Index index)
Copyright © 2024. All rights reserved.