Example usage for com.google.common.primitives UnsignedLong mod

List of usage examples for com.google.common.primitives UnsignedLong mod

Introduction

In this page you can find the example usage for com.google.common.primitives UnsignedLong mod.

Prototype

@CheckReturnValue
public UnsignedLong mod(UnsignedLong val) 

Source Link

Document

Returns this modulo val .

Usage

From source file:org.jpmml.rexp.RandomForestConverter.java

static <E> List<E> selectValues(List<E> values, Double split, boolean left) {
    UnsignedLong bits = toUnsignedLong(split.doubleValue());

    List<E> result = new ArrayList<>();

    for (int i = 0; i < values.size(); i++) {
        E value = values.get(i);// w  ww .  j a  v a 2s  .  c  om

        boolean append;

        // Send "true" categories to the left
        if (left) {
            // Test if the least significant bit (LSB) is 1
            append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ONE);
        } else

        // Send all other categories to the right
        {
            // Test if the LSB is 0
            append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ZERO);
        } // End if

        if (append) {
            result.add(value);
        }

        bits = bits.dividedBy(RandomForestConverter.TWO);
    }

    return result;
}