Example usage for com.google.common.collect Range singleton

List of usage examples for com.google.common.collect Range singleton

Introduction

In this page you can find the example usage for com.google.common.collect Range singleton.

Prototype

public static <C extends Comparable<?>> Range<C> singleton(C value) 

Source Link

Document

Returns a range that Range#contains(Comparable) contains only the given value.

Usage

From source file:net.sf.mzmine.util.RawDataFileUtils.java

public static @Nonnull Range<Double> findTotalRTRange(RawDataFile dataFiles[], int msLevel) {
    Range<Double> rtRange = null;
    for (RawDataFile file : dataFiles) {
        Range<Double> dfRange = file.getDataRTRange(msLevel);
        if (dfRange == null)
            continue;
        if (rtRange == null)
            rtRange = dfRange;//ww  w .ja v  a 2s. c  om
        else
            rtRange = rtRange.span(dfRange);
    }
    if (rtRange == null)
        rtRange = Range.singleton(0.0);
    return rtRange;
}

From source file:com.cinchapi.concourse.server.concurrent.RangeTokens.java

/**
 * Convert the specified range {@code token} to one or more {@link Range
 * ranges} that provide the appropriate coverage.
 * //from   w w w .j a v  a 2 s . c o m
 * @param token
 * @return the Ranges
 */
public static Iterable<Range<Value>> convertToRange(RangeToken token) {
    List<Range<Value>> ranges = Lists.newArrayListWithCapacity(1);
    if (token.getOperator() == Operator.EQUALS || token.getOperator() == null) { // null operator means
                                                                                 // the range token is for
                                                                                 // writing
        ranges.add(Range.singleton(token.getValues()[0]));
    } else if (token.getOperator() == Operator.NOT_EQUALS) {
        ranges.add(Range.lessThan(token.getValues()[0]));
        ranges.add(Range.greaterThan(token.getValues()[0]));
    } else if (token.getOperator() == Operator.GREATER_THAN) {
        ranges.add(Range.greaterThan(token.getValues()[0]));
    } else if (token.getOperator() == Operator.GREATER_THAN_OR_EQUALS) {
        ranges.add(Range.atLeast(token.getValues()[0]));
    } else if (token.getOperator() == Operator.LESS_THAN) {
        ranges.add(Range.lessThan(token.getValues()[0]));
    } else if (token.getOperator() == Operator.LESS_THAN_OR_EQUALS) {
        ranges.add(Range.atMost(token.getValues()[0]));
    } else if (token.getOperator() == Operator.BETWEEN) {
        Value a = token.getValues()[0];
        Value b = token.getValues()[1];
        if (a == Value.NEGATIVE_INFINITY && b == Value.POSITIVE_INFINITY) {
            ranges.add(Range.<Value>all());
        } else if (token.getValues().length == 3) {
            ranges.add(Range.open(a, b));
        } else if (token.getValues().length == 4) {
            ranges.add(Range.closed(a, b));
        } else if (token.getValues().length == 5) {
            ranges.add(Range.openClosed(a, b));
        } else {
            ranges.add(Range.closedOpen(a, b));
        }
    } else if (token.getOperator() == Operator.REGEX || token.getOperator() == Operator.NOT_REGEX) {
        ranges.add(Range.<Value>all());
    } else {
        throw new UnsupportedOperationException();
    }
    return ranges;
}

From source file:com.facebook.presto.sql.planner.optimizations.QueryCardinalityUtil.java

public static boolean isScalar(PlanNode node, Lookup lookup) {
    return Range.singleton(1L).encloses(extractCardinality(node, lookup));
}

From source file:net.sf.mzmine.util.RawDataFileUtils.java

public static @Nonnull Range<Double> findTotalMZRange(RawDataFile dataFiles[], int msLevel) {
    Range<Double> mzRange = null;
    for (RawDataFile file : dataFiles) {
        Range<Double> dfRange = file.getDataMZRange(msLevel);
        if (dfRange == null)
            continue;
        if (mzRange == null)
            mzRange = dfRange;/*from  www  .j  a v  a2 s . c  om*/
        else
            mzRange = mzRange.span(dfRange);
    }
    if (mzRange == null)
        mzRange = Range.singleton(0.0);
    return mzRange;
}

From source file:com.google.eclipse.protobuf.model.util.IndexRanges.java

/**
 * @throws BackwardsRangeException if the end number is less than the start number
 *///from   w  w  w . j a  v  a  2  s  .c  o  m
public Range<Long> toLongRange(IndexRange indexRange) throws BackwardsRangeException {
    long from = indexRange.getFrom();

    Range<Long> range;
    String toString = indexRange.getTo();
    if (toString == null) {
        range = Range.singleton(from);
    } else if (toString.equals(getMaxKeyword())) {
        range = Range.atLeast(from);
    } else {
        Long to = Long.valueOf(toString);

        if (to < from) {
            throw new BackwardsRangeException();
        }

        range = Range.closed(from, to);
    }

    return range;
}

From source file:com.comphenix.protocol.compat.guava.Guava17.java

@Override
public <C extends Comparable<C>> Range<C> singletonRange(C singleton) {
    return Range.singleton(singleton);
}

From source file:org.nmdp.ngs.range.tree.AbstractRangeTree.java

@Override
public int count(final C location) {
    return count(Range.singleton(location));
}

From source file:org.dishevelled.bio.range.entrytree.AbstractRangeTree.java

@Override
public Iterable<Entry<C, V>> query(final C location) {
    return intersect(Range.singleton(location));
}

From source file:org.nmdp.ngs.range.tree.AbstractRangeTree.java

@Override
public Iterable<Range<C>> query(final C location) {
    return intersect(Range.singleton(location));
}

From source file:net.sf.mzmine.datamodel.impl.MZmineToMSDKMsScan.java

/**
 * Clone constructor//from ww w  . ja v  a 2s  .c om
 */
public MZmineToMSDKMsScan(Scan mzmineScan) {
    this.mzmineScan = mzmineScan;
    if (mzmineScan.getPrecursorMZ() != 0) {
        Range<Double> isolationMzRange = Range.singleton(mzmineScan.getPrecursorMZ());
        double precursorMz = mzmineScan.getPrecursorMZ();
        int precursorCharge = mzmineScan.getPrecursorCharge();
        ActivationInfo activationInfo = null;
        isolations.add(
                new SimpleIsolationInfo(isolationMzRange, 0f, precursorMz, precursorCharge, activationInfo));
    }
}