From 4b38895a30d05be4758f1e348dd64a2275cab1f4 Mon Sep 17 00:00:00 2001 From: Matteo Di Giovinazzo Date: Sun, 19 Apr 2020 19:57:19 -0600 Subject: [PATCH] #391 Add Indexer.slice() method to create a new Indexer using the same backing array/buffer/pointer --- src/main/java/org/bytedeco/javacpp/indexer/Indexer.java | 7 +++++++ src/test/java/org/bytedeco/javacpp/IndexerTest.java | 1 + 2 files changed, 8 insertions(+) diff --git a/src/main/java/org/bytedeco/javacpp/indexer/Indexer.java b/src/main/java/org/bytedeco/javacpp/indexer/Indexer.java index d3ad0503a..a0ec57ab5 100644 --- a/src/main/java/org/bytedeco/javacpp/indexer/Indexer.java +++ b/src/main/java/org/bytedeco/javacpp/indexer/Indexer.java @@ -161,6 +161,13 @@ public long index(long... indices) { /** Casts value to primitive type and calls {@code put(long[] indices, 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, diff --git a/src/test/java/org/bytedeco/javacpp/IndexerTest.java b/src/test/java/org/bytedeco/javacpp/IndexerTest.java index b300dada0..3e208297f 100644 --- a/src/test/java/org/bytedeco/javacpp/IndexerTest.java +++ b/src/test/java/org/bytedeco/javacpp/IndexerTest.java @@ -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) { return new TestIndexer(index); } } @Test public void testDefaultStrides() {