io.deephaven.chunk.WritableCharChunkChunk Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-chunk Show documentation
Show all versions of deephaven-engine-chunk Show documentation
Engine Chunks: Array-like data structures for dense, efficient data movement
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.chunk;
import io.deephaven.chunk.attributes.Any;
public class WritableCharChunkChunk extends CharChunkChunk implements WritableChunkChunk {
public static WritableCharChunk[] makeArray(int capacity) {
// noinspection unchecked
return new WritableCharChunk[capacity];
}
public static WritableCharChunkChunk makeWritableChunk(int size) {
return writableChunkWrap(makeArray(size), 0, size);
}
public static WritableCharChunkChunk writableChunkWrap(WritableCharChunk[] data) {
return new WritableCharChunkChunk<>(data, 0, data.length);
}
public static WritableCharChunkChunk writableChunkWrap(WritableCharChunk[] data,
int offset, int size) {
return new WritableCharChunkChunk<>(data, offset, size);
}
/**
* alias of super.data, but of child type
*/
WritableCharChunk[] writableData;
WritableCharChunkChunk(WritableCharChunk[] data, int offset, int capacity) {
super(data, offset, capacity);
this.writableData = data;
}
public final void set(int index, WritableCharChunk value) {
data[offset + index] = value;
resetInnerCacheItem(index, value);
}
@Override
public final WritableCharChunk getWritableChunk(int pos) {
return writableData[offset + pos];
}
@Override
public final void setWritableChunk(int pos, WritableChunk value) {
set(pos, value.asWritableCharChunk());
}
public final void set(int j, int i, char value) {
innerData[j][innerOffsets[j] + i] = value;
}
@Override
public WritableCharChunkChunk slice(int offset, int capacity) {
ChunkHelpers.checkSliceArgs(size, offset, capacity);
return new WritableCharChunkChunk<>(writableData, this.offset + offset, capacity);
}
}