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

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

The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY
// ****** Edit ResettableCharChunk and run "./gradlew replicateSourcesAndChunks" to regenerate
//
// @formatter:off
package io.deephaven.chunk;

import io.deephaven.chunk.attributes.Any;
import io.deephaven.chunk.util.pools.MultiChunkPool;
import io.deephaven.util.type.ArrayTypeUtils;

import static io.deephaven.chunk.util.pools.ChunkPoolConstants.POOL_RESETTABLE_CHUNKS;

/**
 * {@link ResettableReadOnlyChunk} implementation for double data.
 */
public class ResettableDoubleChunk
        extends DoubleChunk
        implements ResettableReadOnlyChunk {

    public static  ResettableDoubleChunk makeResettableChunk() {
        if (POOL_RESETTABLE_CHUNKS) {
            return MultiChunkPool.forThisThread().takeResettableDoubleChunk();
        }
        return new ResettableDoubleChunk<>();
    }

    public static  ResettableDoubleChunk makeResettableChunkForPool() {
        return new ResettableDoubleChunk<>() {
            @Override
            public void close() {
                MultiChunkPool.forThisThread().giveResettableDoubleChunk(this);
            }
        };
    }

    private ResettableDoubleChunk(double[] data, int offset, int capacity) {
        super(data, offset, capacity);
    }

    private ResettableDoubleChunk() {
        this(ArrayTypeUtils.EMPTY_DOUBLE_ARRAY, 0, 0);
    }

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

    @Override
    public  DoubleChunk resetFromChunk(Chunk other, int offset,
            int capacity) {
        return resetFromTypedChunk(other.asDoubleChunk(), offset, capacity);
    }

    @Override
    public  DoubleChunk resetFromArray(Object array, int offset, int capacity) {
        final double[] typedArray = (double[]) array;
        return resetFromTypedArray(typedArray, offset, capacity);
    }

    @Override
    public  DoubleChunk resetFromArray(Object array) {
        final double[] typedArray = (double[]) array;
        return resetFromTypedArray(typedArray, 0, typedArray.length);
    }

    @Override
    public  DoubleChunk clear() {
        return resetFromArray(ArrayTypeUtils.EMPTY_DOUBLE_ARRAY, 0, 0);
    }

    public  DoubleChunk resetFromTypedChunk(DoubleChunk other, int offset,
            int capacity) {
        ChunkHelpers.checkSliceArgs(other.size, offset, capacity);
        return resetFromTypedArray(other.data, other.offset + offset, capacity);
    }

    public  DoubleChunk resetFromTypedArray(double[] data, int offset, int capacity) {
        ChunkHelpers.checkArrayArgs(data.length, offset, capacity);
        this.data = data;
        this.offset = offset;
        this.capacity = capacity;
        this.size = capacity;
        return DoubleChunk.downcast(this);
    }

    @Override
    public void close() {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy