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

com.github.lwhite1.tablesaw.util.collections.IntegerDomain Maven / Gradle / Ivy

package com.github.lwhite1.tablesaw.util.collections;

/**
 * A descriptor for a discrete {@code Comparable} domain such as all
 * {@link Integer} instances. A discrete domain is one that supports the three basic
 * operations: {@link #next}, {@link #previous} and {@link #distance}, according
 * to their specifications. The methods {@link #minValue} and {@link #maxValue}
 * should also be overridden for bounded types.
 * 

*

A discrete domain always represents the entire set of values of its * type; it cannot represent partial domains such as "prime integers" or * "strings of length 5." *

*

See the Guava User Guide section on * {@code IntegerDomain}. * * @author Kevin Bourrillion * @since 10.0 */ final class IntegerDomain { private static final IntegerDomain INSTANCE = new IntegerDomain(); /** * Returns the discrete domain for values of type {@code Integer}. * * @since 14.0 (since 10.0 as {@code DiscreteDomains.integers()}) */ public static IntegerDomain integers() { return INSTANCE; } public Integer next(Integer value) { int i = value; return (i == Integer.MAX_VALUE) ? null : i + 1; } public Integer previous(Integer value) { int i = value; return (i == Integer.MIN_VALUE) ? null : i - 1; } public long distance(Integer start, Integer end) { return (long) end - start; } public Integer minValue() { return Integer.MIN_VALUE; } public Integer maxValue() { return Integer.MAX_VALUE; } private Object readResolve() { return INSTANCE; } @Override public String toString() { return "IntegerDomain.integers()"; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy