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

io.deephaven.chunk.util.hashing.ShortToIntegerCast Maven / Gradle / Ivy

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

import io.deephaven.chunk.*;
import io.deephaven.chunk.attributes.Any;

/**
 * Cast the values in the input chunk to an int.
 *
 * @param  the chunk's attribute
 */
public class ShortToIntegerCast implements ToIntFunctor {
    private final WritableIntChunk result;

    ShortToIntegerCast(int size) {
        result = WritableIntChunk.makeWritableChunk(size);
    }

    @Override
    public IntChunk apply(Chunk input) {
        return cast(input.asShortChunk());
    }

    private IntChunk cast(ShortChunk input) {
        castInto(input, result);
        return result;
    }

    public static  void castInto(ShortChunk input, WritableIntChunk result) {
        for (int ii = 0; ii < input.size(); ++ii) {
            result.set(ii, (int) input.get(ii));
        }
        result.setSize(input.size());
    }

    @Override
    public void close() {
        result.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy