Example usage for com.google.common.math IntMath log10

List of usage examples for com.google.common.math IntMath log10

Introduction

In this page you can find the example usage for com.google.common.math IntMath log10.

Prototype

@GwtIncompatible("need BigIntegerMath to adequately test")
@SuppressWarnings("fallthrough")
public static int log10(int x, RoundingMode mode) 

Source Link

Document

Returns the base-10 logarithm of x , rounded according to the specified rounding mode.

Usage

From source file:edu.washington.cs.cupid.views.InspectorView.java

private Row[] generateArrayRows(final Row parent, final String rootName, final Object array, final int offset,
        final int length) {

    List<Row> result = Lists.newArrayList();

    if (length <= COLLECTION_PARTITION_SIZE) {
        for (int i = 0; i < length; i++) {
            result.add(new ClassRow(parent, rootName + "[" + (i + offset) + "]", Array.get(array, offset + i)));
        }//  w ww. j a va 2  s .  c  om
    } else {
        int depth = IntMath.log10(length - 1, RoundingMode.FLOOR);
        int size = IntMath.pow(COLLECTION_PARTITION_SIZE, depth);
        int cnt = IntMath.divide(length, size, RoundingMode.CEILING);

        for (int i = 0; i < cnt; i++) {
            int start = i * size;
            int end = Math.min(length - 1, start + size - 1);

            result.add(new ArrayRow(parent, rootName, array, offset + start, end - start + 1));
        }
    }

    return result.toArray(new Row[] {});
}

From source file:edu.washington.cs.cupid.views.InspectorView.java

private Row[] generateListRows(final Row parent, final String rootName, final List<?> value, final int offset,
        final int length) {

    List<Row> result = Lists.newArrayList();

    if (length <= COLLECTION_PARTITION_SIZE) {
        for (int i = 0; i < length; i++) {
            result.add(new ClassRow(parent, rootName + "[" + (i + offset) + "]", value.get(i + offset)));
        }/*from   w  w w.j a v a2  s.  c o m*/
    } else {
        int depth = IntMath.log10(length - 1, RoundingMode.FLOOR);
        int size = IntMath.pow(COLLECTION_PARTITION_SIZE, depth);
        int cnt = IntMath.divide(length, size, RoundingMode.CEILING);

        for (int i = 0; i < cnt; i++) {
            int start = i * size;
            int end = Math.min(length - 1, start + size - 1);

            result.add(new ListRow(parent, rootName, value, offset + start, end - start + 1));
        }
    }

    return result.toArray(new Row[] {});
}