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

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

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

TreeSet.subSet介绍

[英]Returns a SortedSet of the specified portion of this TreeSet which contains elements greater or equal to the start element but less than the end element. The returned SortedSet is backed by this TreeSet so changes to one are reflected by the other.
[中]返回此树集指定部分的SortedSet,其中包含大于或等于起始元素但小于结束元素的元素。返回的SortedSet由该树集支持,因此对其中一个树集的更改由另一个树集反映。

代码示例

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

/**
 * Returns a {@code SortedSet} of the specified portion of this {@code TreeSet} which
 * contains elements greater or equal to the start element but less than the
 * end element. The returned SortedSet is backed by this TreeSet so changes
 * to one are reflected by the other.
 *
 * @param start
 *            the start element
 * @param end
 *            the end element
 * @return a subset where the elements are greater or equal to
 *         <code>start</code> and less than <code>end</code>
 *
 * @exception ClassCastException
 *                when the start or end object cannot be compared with the
 *                elements in this TreeSet
 * @exception NullPointerException
 *                when the start or end object is null and the comparator
 *                cannot handle null
 */
@SuppressWarnings("unchecked")
public SortedSet<E> subSet(E start, E end) {
  return subSet(start, true, end, false);
}

代码示例来源:origin: goldmansachs/gs-collections

public MutableSortedSet<T> subSet(T fromElement, T toElement)
{
  return SortedSetAdapter.adapt(this.treeSet.subSet(fromElement, toElement));
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
public MutableSortedSet<T> subSet(T fromElement, T toElement)
{
  return SortedSetAdapter.adapt(this.treeSet.subSet(fromElement, toElement));
}

代码示例来源:origin: eclipse/eclipse-collections

@Override
public MutableSortedSet<T> subSet(T fromElement, T toElement)
{
  return SortedSetAdapter.adapt(this.treeSet.subSet(fromElement, toElement));
}

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

@Override
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
 return set().subSet(fromElement, fromInclusive, toElement, toInclusive);
}

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

@Override
public SortedSet<E> subSet(E fromElement, E toElement) {
 return set().subSet(fromElement, toElement);
}

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

private List<Long> expectedIdsInOrder( NodeValueTuple from, boolean fromInclusive, NodeValueTuple to, boolean toInclusive, IndexOrder indexOrder )
{
  List<Long> expectedIdsInOrder = singlePropValues.subSet( from, fromInclusive, to, toInclusive )
      .stream()
      .map( NodeValueTuple::nodeId )
      .collect( Collectors.toList() );
  if ( indexOrder == IndexOrder.DESCENDING )
  {
    Collections.reverse( expectedIdsInOrder );
  }
  return expectedIdsInOrder;
}

代码示例来源:origin: google/error-prone

private void checkOverlaps(Replacement replacement) {
 Range<Integer> replacementRange = replacement.range();
 Collection<Replacement> overlap =
   overlaps.subRangeMap(replacementRange).asMapOfRanges().values();
 checkArgument(
   overlap.isEmpty(),
   "%s overlaps with existing replacements: %s",
   replacement,
   Joiner.on(", ").join(overlap));
 Set<Integer> containedZeroLengthRangeStarts =
   zeroLengthRanges.subSet(
     replacementRange.lowerEndpoint(),
     /* fromInclusive= */ false,
     replacementRange.upperEndpoint(),
     /* toInclusive= */ false);
 checkArgument(
   containedZeroLengthRangeStarts.isEmpty(),
   "%s overlaps with existing zero-length replacements: %s",
   replacement,
   Joiner.on(", ").join(containedZeroLengthRangeStarts));
 overlaps.put(replacementRange, replacement);
 if (replacementRange.isEmpty()) {
  zeroLengthRanges.add(replacementRange.lowerEndpoint());
 }
}

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

/**
 * Generates a coverage multimap from split key to Regions that start with the
 * split key.
 * 
 * @return coverage multimap
 */
public Multimap<byte[], R> calcCoverage() {
 // This needs to be sorted to force the use of the comparator on the values,
 // otherwise byte array comparison isn't used
 Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR,
   rangeCmp);
 // march through all splits from the start points
 for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) {
  byte[] key = start.getKey();
  for (R r : start.getValue()) {
   regions.put(key, r);
   for (byte[] coveredSplit : splits.subSet(r.getStartKey(),
     specialEndKey(r))) {
    regions.put(coveredSplit, r);
   }
  }
 }
 return regions;
}

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

public List<Long> expectedIds( TreeSet<IndexEntryUpdate> sortedValues, Value booleanValue, Value from, Value to, boolean fromInclusive,
    boolean toInclusive )
{
  return sortedValues.subSet(
            add( 0, descriptor.schema(), booleanValue, from ), fromInclusive,
            add( 0, descriptor.schema(), booleanValue, to ), toInclusive )
            .stream()
            .map( IndexEntryUpdate::getEntityId )
            .sorted( Long::compare )
            .collect( Collectors.toList() );
}

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

private List<Long> expectedIds( TreeSet<IndexEntryUpdate> sortedValues, Value from, Value to, boolean fromInclusive, boolean toInclusive )
{
  return sortedValues.subSet( add( 0, descriptor.schema(), from ), fromInclusive, add( 0, descriptor.schema(), to ), toInclusive )
      .stream()
      .map( IndexEntryUpdate::getEntityId )
      .sorted( Long::compare )
      .collect( Collectors.toList() );
}

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

/**
 * Filter resources from the used model generating a new one containing only resources
 * having the name between from and to string.<br>
 * Note that objects are shared between models so changes to objects in the filtered model
 * will also affect the current model.
 *
 * @param from
 * @param to
 * @return the filtered model
 * @throws IllegalArgumentException if from or to are null
 */
public AboutModel filterNameByRange(String from, String to)
    throws IllegalArgumentException {
  if (from == null || to == null) {
    throw new IllegalArgumentException("Unable to parse from or to are null");
  }
  return new AboutModel(
      getManifests()
          .subSet(new ManifestModel(from), true, new ManifestModel(to), true));
}

代码示例来源:origin: resteasy/Resteasy

@Override
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) {
  return  new UnmodifiableTreeSet<>(super.subSet(fromElement, fromInclusive, toElement, toInclusive));
}

代码示例来源:origin: resteasy/Resteasy

@Override
public SortedSet<E> subSet(E fromElement, E toElement) {
  return  new UnmodifiableTreeSet<>(super.subSet(fromElement, toElement));
}

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

for (TreeSet<Float> xMatch : xMatches.values())
  SortedSet<Float> yMatches = xMatch.subSet(textY - tolerance, textY + tolerance);
  if (!yMatches.isEmpty())

代码示例来源:origin: ron190/jsql-injection

workingSet = this.iniPositions.subSet(startRequest,
    endRequest);
workingIt = workingSet.iterator();
workingIt = this.iniPositions.subSet(dpStart, dpEnd)
    .iterator();
while (workingIt.hasNext()) {

代码示例来源:origin: org.openrdf.alibaba/alibaba-model

public Iterator<Statement> subIterator(Statement fromElement, boolean fromInclusive,
      Statement toElement, boolean toInclusive) {
    return tree.subSet(fromElement, true, toElement, true).iterator();
  }
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections

@Override
public MutableSortedSet<T> subSet(T fromElement, T toElement)
{
  return SortedSetAdapter.adapt(this.treeSet.subSet(fromElement, toElement));
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel

@Override
public NavigableSet subSet(Object fromElement, boolean fromInclusive,
    Object toElement, boolean toInclusive) {
  if (!_directAccess && isDelayLoad()) {
    load();
  }
  return super.subSet(fromElement, fromInclusive, toElement, toInclusive);
}

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

/** Finds all ranges that overlap or touch the given range. */
private NavigableSet<Range> overlaps(int start, int end, boolean includeTouching) {
  // Establish bounds on start times to select ranges that would overlap or touch
  Range startRange = new Range(start, 0);
  Range lower = ranges.lower(startRange);
  if (lower != null && lower.end >= (includeTouching ? start - 1 : start)) {
    // This range would overlap (or touch, if those are to be included)
    startRange = new Range(lower.start, 0);
  }
  Range endRange = new Range(end + 1, 0);
  // Any range with start time within startRange and endRange would touch or overlap
  return ranges.subSet(startRange, true, endRange, includeTouching);
}

相关文章