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

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

Introduction

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

Prototype

public C lowerEndpoint() 

Source Link

Document

Returns the lower endpoint of this range.

Usage

From source file:it.units.malelab.ege.ge.operator.TwoPointsCrossover.java

protected List<BitsGenotype> children(BitsGenotype parent1, Range<Integer> range1, BitsGenotype parent2,
        Range<Integer> range2) {
    int startIndex1 = range1.lowerEndpoint();
    int startIndex2 = range2.lowerEndpoint();
    int endIndex1 = range1.upperEndpoint();
    int endIndex2 = range2.upperEndpoint();
    int child1Size = parent1.size() - (endIndex1 - startIndex1) + (endIndex2 - startIndex2);
    int child2Size = parent2.size() - (endIndex2 - startIndex2) + (endIndex1 - startIndex1);
    BitsGenotype child1 = new BitsGenotype(child1Size);
    BitsGenotype child2 = new BitsGenotype(child2Size);
    if (startIndex1 > 0) {
        child1.set(0, parent1.slice(0, startIndex1));
    }/*from w  ww  .jav a  2  s .com*/
    if (startIndex2 > 0) {
        child2.set(0, parent2.slice(0, startIndex2));
    }
    child1.set(startIndex1, parent2.slice(startIndex2, endIndex2));
    child2.set(startIndex2, parent1.slice(startIndex1, endIndex1));
    if (endIndex1 < parent1.size()) {
        child1.set(startIndex1 + endIndex2 - startIndex2, parent1.slice(endIndex1, parent1.size()));
    }
    if (endIndex2 < parent2.size()) {
        child2.set(startIndex2 + endIndex1 - startIndex1, parent2.slice(endIndex2, parent2.size()));
    }
    return Arrays.asList(child1, child2);
}

From source file:org.graylog2.shared.rest.RangeJsonSerializer.java

@Override
public void serialize(Range range, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    jgen.writeStartObject();//from w  w  w.  ja va 2  s  . co  m
    final Integer lower = (Integer) range.lowerEndpoint();
    final Integer upper = (Integer) range.upperEndpoint();
    jgen.writeNumberField("start", lower);
    jgen.writeNumberField("length", upper - lower);
    jgen.writeEndObject();
}

From source file:net.bican.iplib.IPAddressRangeComparator.java

@Override
public int compare(Range<IPAddress> o1, Range<IPAddress> o2) {
    if (o1.equals(o2)) {
        return 0;
    }//  w ww  .  j a  va 2  s  .  c  o m
    Range<IPAddress> oo1 = IPAddresses.canonical(o1, o1.lowerEndpoint().getDomain());
    Range<IPAddress> oo2 = IPAddresses.canonical(o2, o2.lowerEndpoint().getDomain());
    return oo1.lowerEndpoint().compareTo(oo2.lowerEndpoint());
}

From source file:org.mskcc.shenkers.view.RangeSetIntervalView.java

public void setData(RangeSet<Integer> intervals) {
    for (Range<Integer> interval : intervals.asRanges()) {
        Range<Double> r = Range.closed((interval.lowerEndpoint() - min + 0.) / length,
                (interval.upperEndpoint() - min + 1.) / length);
        logger.info("range {}", r);
        ranges.add(r);//from   ww  w  .j av a  2 s  . c om
    }

    List<Node> content = new ArrayList<>();
    for (Range<Double> interval : ranges.subRangeSet(Range.closed(0., 1.)).asRanges()) {
        Rectangle rectangle = new Rectangle();

        rectangle.widthProperty()
                .bind(widthProperty().multiply(interval.upperEndpoint() - interval.lowerEndpoint()));
        rectangle.heightProperty().bind(heightProperty());
        rectangle.xProperty().bind(widthProperty().multiply(interval.lowerEndpoint()));

        content.add(rectangle);
    }

    getChildren().setAll(content);
}

From source file:io.github.mzmine.parameters.parametertypes.ranges.IntegerRangeEditor.java

@Override
public void setValue(Range<Integer> value) {
    if (value == null)
        return;/*from w  w w.  j a  v a2s  .c  om*/
    String minValue = String.valueOf(value.lowerEndpoint());
    String maxValue = String.valueOf(value.upperEndpoint());
    minTxtField.setText(minValue);
    maxTxtField.setText(maxValue);
}

From source file:edu.cmu.sv.modelinference.eventtool.classification.ClassificationResult.java

/**
 * returns a sorted set./*from w  w w  .j av  a2  s. com*/
 * Yes, I wish treemap would return SortedSet instead of Set, 
 * because Set does not provide guarantee on iteration order even 
 * though the Set returned by entrySet does indeed preserve natural order...
 */
public Set<Map.Entry<Event, EventClass>> getEvtSeqWithClassifiers() {
    SortedMap<Event, EventClass> evtMap = new TreeMap<>(new Comparator<Event>() {
        @Override
        public int compare(Event o1, Event o2) {
            Range<Integer> o1Range = o1.getRange();
            Range<Integer> o2Range = o2.getRange();
            return o1Range.lowerEndpoint() - o2Range.lowerEndpoint();
        }
    });

    for (EventClass cl : results) {
        for (Event evt : cl) {
            evtMap.put(evt, cl);
        }
    }
    return evtMap.entrySet();
}

From source file:org.onosproject.store.resource.impl.EncodedDiscreteResources.java

Class<?> encodedClass() {
    Range<Integer> firstRange = rangeSet.asRanges().iterator().next();
    return codec.decode(firstRange.lowerEndpoint()).getClass();
}

From source file:org.mskcc.shenkers.view.GeneViewBuilder.java

public T getView(int start, int end) {
    GenericIntervalView<T> giv = new GenericIntervalView<>(gene.lowerEndpoint(), gene.upperEndpoint());
    List<Pair<Integer, Integer>> ranges = new ArrayList<>();
    List<T> panes = new ArrayList<>();

    for (Range<Integer> r : codingSubset.subRangeSet(Range.closed(start, end)).asRanges()) {
        ranges.add(new Pair<>(r.lowerEndpoint(), r.upperEndpoint()));

        panes.add((T) new GenePartIntervalNode<T>(1., (T) new RectangleIntervalNode()));
    }/*from   w w w. ja  va 2 s .co m*/
    for (Range<Integer> r : untranslated.subRangeSet(Range.closed(start, end)).asRanges()) {
        ranges.add(new Pair<>(r.lowerEndpoint(), r.upperEndpoint()));
        panes.add((T) new GenePartIntervalNode<T>(.5, (T) new RectangleIntervalNode()));
    }
    for (Range<Integer> r : introns.subRangeSet(Range.closed(start, end)).asRanges()) {
        ranges.add(new Pair<>(r.lowerEndpoint(), r.upperEndpoint()));
        panes.add((T) new GenePartIntervalNode<T>(.1, (T) new RectangleIntervalNode()));
    }
    giv.setData(ranges, panes);
    return (T) giv;
}

From source file:org.noroomattheinn.timeseries.InMemoryTS.java

@Override
public NavigableMap<Long, Row> getIndex(Range<Long> period) {
    long from = period.hasLowerBound() ? period.lowerEndpoint() : 0;
    long to = period.hasUpperBound() ? period.upperEndpoint() : Long.MAX_VALUE;
    return index.subMap(from, true, to, true);
}

From source file:org.sonatype.nexus.repository.partial.PartialPayload.java

/**
 * The endpoints of the Range are interpreted as the first and last byte positions to send.
 *//*from w ww .  j  av a 2  s.  co  m*/
public PartialPayload(final Payload payload, final Range<Long> rangeToSend) {
    this.payload = payload;
    this.rangeToSend = rangeToSend;
    this.partialSize = 1 + rangeToSend.upperEndpoint() - rangeToSend.lowerEndpoint();
}