public IntDataBuffer copyTo()

in ndarray/src/main/java/org/tensorflow/ndarray/impl/buffer/raw/IntRawDataBuffer.java [63:97]


  public IntDataBuffer copyTo(DataBuffer<Integer> dst, long size) {
    Validator.copyToArgs(this, dst, size);
    return dst.accept(new DataStorageVisitor<IntDataBuffer>() {

      @Override
      public IntDataBuffer visit(IntBuffer buffer) {
        if (buffer.hasArray()) {
          memory.copyTo(UnsafeMemoryHandle.fromArray(buffer.array(), buffer.position(), buffer.limit()), size);
        } else if (memory.isArray()) {
          buffer.put(memory.toArrayIntBuffer());
        } else {
          slowCopyTo(dst, size);
        }
        return IntRawDataBuffer.this;
      }

      @Override
      public IntDataBuffer visit(long address, long length, long scale) {
        memory.copyTo(UnsafeMemoryHandle.fromAddress(address, length, scale), size);
        return IntRawDataBuffer.this;
      }

      @Override
      public IntDataBuffer fallback() {
        if (dst instanceof IntDataBuffer) {
          IntDataBuffer intDst = (IntDataBuffer)dst;
          for (long idx = 0L; idx < size; ++idx) {
            intDst.setInt(getInt(idx), idx);
          }
          return IntRawDataBuffer.this;
        }
        return slowCopyTo(dst, size);
      }
    });
  }