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

io.virtdata.libbasics.shared.from_long.to_long.HashRangeScaled Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
package io.virtdata.libbasics.shared.from_long.to_long;

import io.virtdata.annotations.ThreadSafeMapper;

import java.util.function.LongUnaryOperator;

/**
 * Return a pseudo-random value which can only be as large as the input.
 */
@ThreadSafeMapper
public class HashRangeScaled implements LongUnaryOperator {

    private Hash hash = new Hash();

    public HashRangeScaled() {
    }

    @Override
    public long applyAsLong(long operand) {
        if (operand==0) { return 0; }
        long hashed = hash.applyAsLong(operand);
        return hashed % operand;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy