All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.chunk.ResettableCharChunkChunk Maven / Gradle / Ivy

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 ResettableCharChunkChunk extends CharChunkChunk
        implements ResettableChunkChunk {

    public static  ResettableCharChunkChunk makeResettableChunk() {
        return new ResettableCharChunkChunk<>();
    }

    private ResettableCharChunkChunk(CharChunk[] data, int offset, int capacity) {
        super(data, offset, capacity);
    }

    private ResettableCharChunkChunk() {
        this(CharChunk.getEmptyChunkArray(), 0, 0);
    }

    @Override
    public ResettableCharChunkChunk slice(int offset, int capacity) {
        ChunkHelpers.checkSliceArgs(size, offset, capacity);
        return new ResettableCharChunkChunk<>(data, this.offset + offset, capacity);
    }

    @Override
    public final void resetFromChunk(ChunkChunk other, int offset, int capacity) {
        resetFromTypedChunk(other.asCharChunkChunk(), offset, capacity);
    }

    @Override
    public final void resetFromArray(Object array, int offset, int capacity) {
        // noinspection unchecked
        final CharChunk[] typedArray = (CharChunk[]) array;
        resetFromTypedArray(typedArray, offset, capacity);
    }

    public final void resetFromTypedChunk(CharChunkChunk other, int offset, int capacity) {
        ChunkHelpers.checkSliceArgs(other.size, offset, capacity);
        resetFromTypedArray(other.data, other.offset + offset, capacity);
    }

    public final void resetFromTypedArray(CharChunk[] data, int offset, int capacity) {
        ChunkHelpers.checkArrayArgs(data.length, offset, capacity);
        this.data = data;
        this.offset = offset;
        this.capacity = capacity;
        this.size = capacity;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy