List of usage examples for com.google.common.collect Range upperEndpoint
public C upperEndpoint()
From source file:org.corpus_tools.peppermodules.annis.Audio2ANNISMapper.java
private void outputVirtualTokenAnnotations() { for (Map.Entry<Long, Range<Double>> e : virtTokenTimes.entrySet()) { Range<Double> r = e.getValue(); String val = null; if (r.hasLowerBound() && r.hasUpperBound()) { val = r.lowerEndpoint() + "-" + r.upperEndpoint(); } else if (r.hasLowerBound()) { val = "" + r.lowerEndpoint(); } else if (r.hasUpperBound()) { val = "-" + r.upperEndpoint(); }//w w w .j av a2 s . co m if (val != null) { mapSNodeAnnotation(e.getKey(), "annis", "time", val); } } }
From source file:io.horizondb.model.core.blocks.AbstractDataBlock.java
/** * {@inheritDoc}/*from ww w. j a va2 s.c o m*/ */ @Override public final RangeMap<Field, DataBlock> split(TimeSeriesDefinition definition) throws IOException { Range<Field> range = BlockHeaderUtils.getRange(getHeader()); Range<Field> partitionRange = definition.getPartitionTimeRange(range.lowerEndpoint()); if (partitionRange.contains(range.upperEndpoint())) { return ImmutableRangeMap.<Field, DataBlock>of(partitionRange, this); } TimeSeriesRecord[] records = definition.newRecords(); ImmutableRangeMap.Builder<Field, DataBlock> builder = ImmutableRangeMap.builder(); RecordAppender appender = new RecordAppender(definition, Buffers.getDefaultAllocator(), records); Field[] timestamps = new Field[records.length]; for (int i = 0; i < timestamps.length; i++) { timestamps[i] = definition.newField(Record.TIMESTAMP_FIELD_NAME); } try (BinaryTimeSeriesRecordIterator iterator = new BinaryTimeSeriesRecordIterator(definition, singleton(this))) { while (iterator.hasNext()) { Record record = iterator.next(); Field timestamp = timestamps[record.getType()]; if (record.isDelta()) { timestamp.add(record.getField(Record.TIMESTAMP_FIELD_INDEX)); } else { record.getField(Record.TIMESTAMP_FIELD_INDEX).copyTo(timestamp); } if (!partitionRange.contains(timestamp)) { builder.put(partitionRange, appender.getDataBlock()); partitionRange = definition.getPartitionTimeRange(timestamp); appender = new RecordAppender(definition, Buffers.getDefaultAllocator(), records); } appender.append(record); } builder.put(partitionRange, appender.getDataBlock()); } return builder.build(); }
From source file:it.units.malelab.ege.ge.mapper.HierarchicalMapper.java
protected List<Range<Integer>> getChildrenSlices(Range<Integer> range, List<T> symbols) { List<Range<Integer>> ranges; if (symbols.size() > (range.upperEndpoint() - range.lowerEndpoint())) { ranges = new ArrayList<>(symbols.size()); for (T symbol : symbols) { ranges.add(Range.closedOpen(range.lowerEndpoint(), range.lowerEndpoint())); }//from w w w .jav a 2s. c o m } else { ranges = Utils.slices(range, symbols.size()); } return ranges; }
From source file:com.axemblr.provisionr.api.network.RuleBuilder.java
public RuleBuilder ports(Range<Integer> ports) { checkArgument(ports.hasUpperBound(), "ports should have a closed upper bound"); checkArgument(ports.hasLowerBound(), "ports should have a closed lower bound "); checkArgument(ports.lowerEndpoint() > 0, "ports should be a positive range"); checkArgument(ports.upperEndpoint() < 65535, "ports upper bound should less than 65535"); this.ports = checkNotNull(ports, "ports is null"); return this; }
From source file:org.apache.provisionr.api.network.RuleBuilder.java
public RuleBuilder ports(Range<Integer> ports) { checkArgument(ports.hasUpperBound(), "ports should have a closed upper bound"); checkArgument(ports.hasLowerBound(), "ports should have a closed lower bound "); checkArgument(ports.lowerEndpoint() > 0, "ports should be a positive range"); checkArgument(ports.upperEndpoint() < Machine.MAX_PORT_NUMBER, "ports upper bound should less than 65535"); this.ports = checkNotNull(ports, "ports is null"); return this; }
From source file:com.wealdtech.collect.TreeRangedMap.java
@Override public void put(final Range<K> key, final V value) { validateRange(key);//from w ww .ja v a2 s.co m K resultantStart = key.lowerEndpoint(); K resultantEnd = key.upperEndpoint(); // Truncate or coalesce anything which overlaps the start of our new entry final Map.Entry<K, TwoTuple<Range<K>, V>> prior = getEntry(key.lowerEndpoint()); if (prior != null) { if (prior.getValue().getT().equals(value)) { // Values are the same so we can coalesce. if (resultantEnd.compareTo(prior.getValue().getS().upperEndpoint()) < 0) { // Existing entry already covers this; we don't have to do anything more return; } underlying.remove(prior.getKey()); // Set our start to the start of the prior entry resultantStart = prior.getKey(); } else { // Values are different; truncate prior item underlying.put(prior.getKey(), new TwoTuple<>(Range.closedOpen(prior.getKey(), resultantStart), prior.getValue().getT())); // If the prior entry stretches beyond the new entry we also need to put in our remaining item if (resultantEnd.compareTo(prior.getValue().getS().upperEndpoint()) < 0) { underlying.put(resultantEnd, new TwoTuple<>(Range.closedOpen(resultantEnd, prior.getValue().getS().upperEndpoint()), prior.getValue().getT())); } } } // Remove any items which are covered by our new entry, and truncate or coalesce anything which overlaps the end of it Map.Entry<K, TwoTuple<Range<K>, V>> potentialVictim = underlying.ceilingEntry(resultantStart); while (potentialVictim != null) { if (key.encloses(potentialVictim.getValue().getS())) { // Totally enclosed; remove it underlying.remove(potentialVictim.getKey()); potentialVictim = underlying.ceilingEntry(resultantStart); } else if (key.contains(potentialVictim.getKey())) { // Partial overlap if (potentialVictim.getValue().getT().equals(value)) { // Values are the same so we can coalesce. Remove the entry and update our bounds accordingly resultantEnd = potentialVictim.getValue().getS().upperEndpoint(); underlying.remove(potentialVictim.getKey()); } else { // Values are different; truncate victim item underlying.remove(potentialVictim.getKey()); underlying.put(resultantEnd, new TwoTuple<>( Range.closedOpen(resultantEnd, potentialVictim.getValue().getS().upperEndpoint()), potentialVictim.getValue().getT())); } potentialVictim = null; } else { // No relationship potentialVictim = null; } } // Write out our final result underlying.put(resultantStart, new TwoTuple<>(Range.closedOpen(resultantStart, resultantEnd), value)); }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.RedKeywordProposal.java
@Override public List<String> getArguments() { if (EmbeddedKeywordNamesSupport.hasEmbeddedArguments(getNameFromDefinition())) { return new ArrayList<>(); } else {/* w w w . j a va 2s. co m*/ final List<String> arguments = newArrayList( transform(getArgumentsDescriptor().getRequiredArguments(), new Function<Argument, String>() { @Override public String apply(final Argument arg) { return arg.getName(); } })); final Range<Integer> noOfArgs = getArgumentsDescriptor().getPossibleNumberOfArguments(); final boolean mayHaveMoreArguments = !noOfArgs.hasUpperBound() || noOfArgs.upperEndpoint() > arguments.size(); if (mayHaveMoreArguments) { arguments.add(""); } return arguments; } }
From source file:com.yahoo.gondola.container.AdminClient.java
/** * Split shard.// www .jav a 2s . com * * @param fromShardId the from shard id * @param toShardId the to shard id * @throws AdminException the admin exception */ public void splitShard(String fromShardId, String toShardId) throws AdminException, InterruptedException { Range<Integer> range = lookupSplitRange(fromShardId, toShardId); assignBuckets(range.lowerEndpoint(), range.upperEndpoint(), fromShardId, toShardId); }
From source file:com.yahoo.gondola.container.AdminClient.java
/** * Merge shard./*from ww w. ja v a 2s. c o m*/ * * @param fromShardId the from shard id * @param toShardId the to shard id * @throws AdminException the admin exception */ public void mergeShard(String fromShardId, String toShardId) throws AdminException, InterruptedException { Range<Integer> range = lookupMergeRange(fromShardId, toShardId); assignBuckets(range.lowerEndpoint(), range.upperEndpoint(), fromShardId, toShardId); }
From source file:net.sf.mzmine.modules.visualization.threed.ThreeDPeakCells.java
/** * Create a peak bounding box./*from w w w.j a v a2 s. c o m*/ * * @param peak * the peak. * @return the bounding box as a gridded set. * @throws VisADException * if there are VisAD problems. */ private Data createPeakBox(final Feature peak) throws VisADException { // Get the extents. final Range<Double> rtRange = peak.getRawDataPointsRTRange(); final Range<Double> mzRange = peak.getRawDataPointsMZRange(); final float rtMin = rtRange.lowerEndpoint().floatValue(); final float rtMax = rtRange.upperEndpoint().floatValue(); final float mzMin = mzRange.lowerEndpoint().floatValue(); final float mzMax = mzRange.upperEndpoint().floatValue(); final float heightMin = 1.0f; final float heightMax = peak.getRawDataPointsIntensityRange().upperEndpoint().floatValue(); // Create the box set. return GriddedSet.create(pointTupleType, new float[][] { { rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMax, rtMin, rtMin, rtMin, rtMin, rtMax, rtMax, rtMax, rtMax, }, { mzMin, mzMin, mzMin, mzMin, mzMax, mzMax, mzMax, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax, mzMin, mzMax }, { heightMin, heightMin, heightMax, heightMax, heightMax, heightMax, heightMin, heightMin, heightMin, heightMin, heightMax, heightMax, heightMax, heightMax, heightMin, heightMin } }, new int[] { 2, 8 }); }