import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";

/**
 *
 * @param {number[]|Float32Array|Float64Array|ArrayLike<number>} values
 * @returns {number}
 */
export function computeHashFloatArray(values) {
    const dataLength = values.length;

    let hash = dataLength;

    for (let i = 0; i < dataLength; i++) {
        const singleValue = values[i];

        //scale value to integer range
        const integerValue = computeHashFloat(singleValue);

        hash = ((hash << 5) - hash) + integerValue;
        hash |= 0; // Convert to 32bit integer
    }

    return hash;
}
