Skip to content

Commit

Permalink
bytedeco#391 Add Indexer.slice() method to create a new Indexer using…
Browse files Browse the repository at this point in the history
… the same backing array/buffer/pointer
  • Loading branch information
matteodg committed Apr 20, 2020
1 parent 34c5f3d commit 8c5d3f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/org/bytedeco/javacpp/indexer/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ public long index(long... indices) {
/** Casts value to primitive type and calls {@code put(long[] indices, <type> value)}. */
public abstract Indexer putDouble(long[] indices, double value);

/**
* TODO
* @param index
* @return
*/
public abstract Indexer slice(Index index);

@Override public String toString() {
long rows = sizes.length > 0 ? sizes[0] : 1,
cols = sizes.length > 1 ? sizes[1] : 1,
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/bytedeco/javacpp/IndexerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static class TestIndexer extends Indexer {
public void release() { }
public double getDouble(long... indices) { return 0; }
public Indexer putDouble(long[] indices, double value) { return this; }
public Indexer slice(Index index) { throw new UnsupportedOperationException("Not implemented"); }
}

@Test public void testDefaultStrides() {
Expand Down

0 comments on commit 8c5d3f1

Please sign in to comment.