java.util.TreeSet.floor()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中java.util.TreeSet.floor()方法的一些代码示例,展示了TreeSet.floor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeSet.floor()方法的具体详情如下:
包路径:java.util.TreeSet
类名称:TreeSet
方法名:floor

TreeSet.floor介绍

暂无

代码示例

代码示例来源:origin: google/ExoPlayer

/**
 * When provided with a byte offset, this method locates the cached region within which the
 * offset falls, and returns the approximate end position in milliseconds of that region. If the
 * byte offset does not fall within a cached region then {@link #NOT_CACHED} is returned.
 * If the cached region extends to the end of the stream, {@link #CACHED_TO_END} is returned.
 *
 * @param byteOffset The byte offset in the underlying stream.
 * @return The end position of the corresponding cache region, {@link #NOT_CACHED}, or
 *     {@link #CACHED_TO_END}.
 */
public synchronized int getRegionEndTimeMs(long byteOffset) {
 lookupRegion.startOffset = byteOffset;
 Region floorRegion = regions.floor(lookupRegion);
 if (floorRegion == null || byteOffset > floorRegion.endOffset
   || floorRegion.endOffsetIndex == -1) {
  return NOT_CACHED;
 }
 int index = floorRegion.endOffsetIndex;
 if (index == chunkIndex.length - 1
   && floorRegion.endOffset == (chunkIndex.offsets[index] + chunkIndex.sizes[index])) {
  return CACHED_TO_END;
 }
 long segmentFractionUs = (chunkIndex.durationsUs[index]
   * (floorRegion.endOffset - chunkIndex.offsets[index])) / chunkIndex.sizes[index];
 return (int) ((chunkIndex.timesUs[index] + segmentFractionUs) / 1000);
}

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns the largest key in this set less than or equal to {@code key}.
 *
 * @param  key the key
 * @return the largest key in this set table less than or equal to {@code key}
 * @throws IllegalArgumentException if {@code key} is {@code null}
 * @throws NoSuchElementException if there is no such key
 */
public Key floor(Key key) {
  if (key == null) throw new IllegalArgumentException("called floor() with a null key");
  Key k = set.floor(key);
  if (k == null) throw new NoSuchElementException("all keys are greater than " + key);
  return k;
}

代码示例来源:origin: apache/kylin

@Override
  public String next() {
    String r = input.next();
    if (cache.size() < card) {
      cache.add(r);
      return r;
    }
    r = cache.floor(r);
    return r == null ? cache.first() : r;
  }
}

代码示例来源:origin: apache/incubator-druid

@Override
public Optional<Interval> bucketInterval(DateTime dt)
{
 // First interval with start time ≤ dt
 final Interval interval = intervals.floor(new Interval(dt, DateTimes.MAX));
 if (interval != null && interval.contains(dt)) {
  return Optional.of(interval);
 } else {
  return Optional.absent();
 }
}

代码示例来源:origin: atomix/atomix

@Override
public E floor(E e) {
 return set().floor(e);
}

代码示例来源:origin: oracle/opengrok

public Scope getScope(int line) {
  // find closest scope that starts before or on given line
  Scope s = scopes.floor(new Scope(line));
  return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE;
}

代码示例来源:origin: google/ExoPlayer

@Override
public synchronized void onSpanRemoved(Cache cache, CacheSpan span) {
 Region removedRegion = new Region(span.position, span.position + span.length);
 // Look up a region this span falls into.
 Region floorRegion = regions.floor(removedRegion);
 if (floorRegion == null) {
  Log.e(TAG, "Removed a span we were not aware of");
  return;
 }
 // Remove it.
 regions.remove(floorRegion);
 // Add new floor and ceiling regions, if necessary.
 if (floorRegion.startOffset < removedRegion.startOffset) {
  Region newFloorRegion = new Region(floorRegion.startOffset, removedRegion.startOffset);
  int index = Arrays.binarySearch(chunkIndex.offsets, newFloorRegion.endOffset);
  newFloorRegion.endOffsetIndex = index < 0 ? -index - 2 : index;
  regions.add(newFloorRegion);
 }
 if (floorRegion.endOffset > removedRegion.endOffset) {
  Region newCeilingRegion = new Region(removedRegion.endOffset + 1, floorRegion.endOffset);
  newCeilingRegion.endOffsetIndex = floorRegion.endOffsetIndex;
  regions.add(newCeilingRegion);
 }
}

代码示例来源:origin: apache/incubator-gobblin

URI floor = uriSet.floor(u);

代码示例来源:origin: google/ExoPlayer

private void mergeSpan(CacheSpan span) {
 Region newRegion = new Region(span.position, span.position + span.length);
 Region floorRegion = regions.floor(newRegion);
 Region ceilingRegion = regions.ceiling(newRegion);
 boolean floorConnects = regionsConnect(floorRegion, newRegion);

代码示例来源:origin: google/ExoPlayer

/**
 * Returns the span containing the position. If there isn't one, it returns a hole span
 * which defines the maximum extents of the hole in the cache.
 */
public SimpleCacheSpan getSpan(long position) {
 SimpleCacheSpan lookupSpan = SimpleCacheSpan.createLookup(key, position);
 SimpleCacheSpan floorSpan = cachedSpans.floor(lookupSpan);
 if (floorSpan != null && floorSpan.position + floorSpan.length > position) {
  return floorSpan;
 }
 SimpleCacheSpan ceilSpan = cachedSpans.ceiling(lookupSpan);
 return ceilSpan == null ? SimpleCacheSpan.createOpenHole(key, position)
   : SimpleCacheSpan.createClosedHole(key, position, ceilSpan.position - position);
}

代码示例来源:origin: wdullaer/MaterialDateTimePicker

Timepoint floor = exclusiveSelectableTimes.floor(current);
return !(current.equals(ceil, Timepoint.TYPE.HOUR) || current.equals(floor, Timepoint.TYPE.HOUR));
Timepoint floor = mDisabledTimes.floor(current);
return current.equals(ceil, Timepoint.TYPE.HOUR) || current.equals(floor, Timepoint.TYPE.HOUR);
Timepoint floor = exclusiveSelectableTimes.floor(current);
return !(current.equals(ceil, Timepoint.TYPE.MINUTE) || current.equals(floor, Timepoint.TYPE.MINUTE));
Timepoint floor = mDisabledTimes.floor(current);
boolean ceilExclude = current.equals(ceil, Timepoint.TYPE.MINUTE);
boolean floorExclude = current.equals(floor, Timepoint.TYPE.MINUTE);

代码示例来源:origin: wdullaer/MaterialDateTimePicker

Timepoint forwardFloor = mDisabledTimes.floor(forward);
if (!forward.equals(forwardCeil, resolution) && !forward.equals(forwardFloor, resolution))
  return forward;
Timepoint backwardFloor = mDisabledTimes.floor(backward);
if (!backward.equals(backwardCeil, resolution) && !backward.equals(backwardFloor, resolution))
  return backward;

代码示例来源:origin: apache/kylin

try {
  int id = dict.getIdFromValue(query, -1);
  assertEquals(set.floor(query), dict.getValueFromId(id));
} catch (IllegalArgumentException e) {
  assertNull(set.floor(query));

代码示例来源:origin: wdullaer/MaterialDateTimePicker

Timepoint floor = exclusiveSelectableTimes.floor(time);
Timepoint ceil = exclusiveSelectableTimes.ceiling(time);
  Timepoint floor = mDisabledTimes.floor(time);
  boolean ceilDisabled = time.equals(ceil, Timepoint.TYPE.MINUTE);
  boolean floorDisabled = time.equals(floor, Timepoint.TYPE.MINUTE);
  Timepoint floor = mDisabledTimes.floor(time);
  boolean ceilDisabled = time.equals(ceil, Timepoint.TYPE.HOUR);
  boolean floorDisabled = time.equals(floor, Timepoint.TYPE.HOUR);

代码示例来源:origin: apache/kylin

try {
  int id = dict.getIdFromValue(query, -1);
  assertEquals(set.floor(query), dict.getValueFromId(id));
} catch (IllegalArgumentException e) {
  assertNull(set.floor(query));

代码示例来源:origin: apache/kylin

try {
  int id = dict.getIdFromValue(query, -1);
  assertEquals(set.floor(query), dict.getValueFromId(id));
} catch (IllegalArgumentException e) {
  assertNull(set.floor(query));

代码示例来源:origin: apache/accumulo

synchronized void waitForWrites(TabletType ttype) {
 long operationId = operationCounter.getAndIncrement();
 while (inProgressWrites.get(ttype).floor(operationId) != null) {
  try {
   this.wait();
  } catch (InterruptedException e) {
   log.error("{}", e.getMessage(), e);
  }
 }
}

代码示例来源:origin: pravega/pravega

@Override
public long getClosestValidTruncationPoint(long sequenceNumber) {
  Long result;
  synchronized (this.truncationMarkers) {
    result = this.truncationPoints.floor(sequenceNumber);
  }
  return result == null ? Operation.NO_SEQUENCE_NUMBER : result;
}

代码示例来源:origin: freenet/fred

/**
 * Checks whether all slots between start and end (inclusive) are present.
 */
public boolean contains(int start, int end) {
  if(start > end) {
    throw new IllegalArgumentException("Tried checking bad range. Start: " + start + ", end: " + end);
  }
  // Find the latest range starting before (or at) start, if any exists.
  Range floor = ranges.floor(new Range(start, end));
  // By definition of floor(), lower.start <= start.
  return floor != null && floor.end >= end;
}

代码示例来源:origin: au.gov.amsa.risky/geo-analyzer

public Optional<Cell> cellAt(double lat, double lon) {
  if (!options.getFilterBounds().contains(lat, lon))
    return Optional.absent();
  else {
    Long latIndex = latIndexes.get(lats.ceiling(lat));
    Long lonIndex = lonIndexes.get(lons.floor(lon));
    return Optional.of(new Cell(latIndex, lonIndex));
  }
}

相关文章