类java.util.NavigableSet源码实例Demo

下面列出了怎么用java.util.NavigableSet的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop-ozone   文件: SCMContainerManager.java
/**
 * Returns the container ID's matching with specified owner.
 * @param pipeline
 * @param owner
 * @return NavigableSet<ContainerID>
 */
private NavigableSet<ContainerID> getContainersForOwner(
    Pipeline pipeline, String owner) throws IOException {
  NavigableSet<ContainerID> containerIDs =
      pipelineManager.getContainersInPipeline(pipeline.getId());
  Iterator<ContainerID> containerIDIterator = containerIDs.iterator();
  while (containerIDIterator.hasNext()) {
    ContainerID cid = containerIDIterator.next();
    try {
      if (!getContainer(cid).getOwner().equals(owner)) {
        containerIDIterator.remove();
      }
    } catch (ContainerNotFoundException e) {
      LOG.error("Could not find container info for container id={} {}", cid,
          e);
      containerIDIterator.remove();
    }
  }
  return containerIDs;
}
 
源代码2 项目: dragonwell8_jdk   文件: EmptyNavigableSet.java
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testheadSetRanges(String description, NavigableSet navigableSet) {
    NavigableSet subSet = navigableSet.headSet(BigInteger.ONE, true);

    // same subset
    subSet.headSet(BigInteger.ONE, true);

    // slightly smaller
    NavigableSet ns = subSet.headSet(BigInteger.ONE, false);

    // slight exapansion
    assertThrows(() -> {
        ns.headSet(BigInteger.ONE, true);
    },
        IllegalArgumentException.class,
        description + ": Expansion should not be allowed");

    // much smaller
    subSet.headSet(isDescending(subSet) ? BigInteger.TEN : BigInteger.ZERO, true);
}
 
@java.lang.SuppressWarnings("all")
@javax.annotation.Generated("lombok")
public SingularNavigableSet2<T> build() {
	java.util.NavigableSet<java.lang.Object> rawTypes = new java.util.TreeSet<java.lang.Object>();
	if (this.rawTypes != null) rawTypes.addAll(this.rawTypes);
	rawTypes = java.util.Collections.unmodifiableNavigableSet(rawTypes);
	java.util.NavigableSet<Integer> integers = new java.util.TreeSet<Integer>();
	if (this.integers != null) integers.addAll(this.integers);
	integers = java.util.Collections.unmodifiableNavigableSet(integers);
	java.util.NavigableSet<T> generics = new java.util.TreeSet<T>();
	if (this.generics != null) generics.addAll(this.generics);
	generics = java.util.Collections.unmodifiableNavigableSet(generics);
	java.util.NavigableSet<Number> extendsGenerics = new java.util.TreeSet<Number>();
	if (this.extendsGenerics != null) extendsGenerics.addAll(this.extendsGenerics);
	extendsGenerics = java.util.Collections.unmodifiableNavigableSet(extendsGenerics);
	return new SingularNavigableSet2<T>(rawTypes, integers, generics, extendsGenerics);
}
 
public void testSubSetContents2() {
    NavigableSet set = set5();
    SortedSet sm = set.subSet(two, three);
    assertEquals(1, sm.size());
    assertEquals(two, sm.first());
    assertEquals(two, sm.last());
    assertFalse(sm.contains(one));
    assertTrue(sm.contains(two));
    assertFalse(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    assertFalse(i.hasNext());
    Iterator j = sm.iterator();
    j.next();
    j.remove();
    assertFalse(set.contains(two));
    assertEquals(4, set.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertFalse(sm.remove(three));
    assertEquals(4, set.size());
}
 
源代码5 项目: kylin   文件: ExecutableDao.java
public List<String> getJobIds() throws PersistentException {
    try {
        NavigableSet<String> resources = store.listResources(ResourceStore.EXECUTE_RESOURCE_ROOT);
        if (resources == null) {
            return Collections.emptyList();
        }
        ArrayList<String> result = Lists.newArrayListWithExpectedSize(resources.size());
        for (String path : resources) {
            result.add(path.substring(path.lastIndexOf("/") + 1));
        }
        return result;
    } catch (IOException e) {
        logger.error("error get all Jobs:", e);
        throw new PersistentException(e);
    }
}
 
源代码6 项目: ambry   文件: IndexSegmentTest.java
/**
 * Gets some IDs for ttl update. Picks the first half of ids from {@code referenceIndex} and also randomly generates
 * {@code outOfSegmentIdCount} ids.
 * @param referenceIndex the index entries to pick for ttl update from.
 * @param outOfSegmentIdCount the number of ids to be generated that are not in {@code referenceIndex}.
 * @return a {@link Set} of IDs to create ttl update entries for.
 */
private Set<MockId> getIdsToTtlUpdate(NavigableMap<MockId, NavigableSet<IndexValue>> referenceIndex,
    int outOfSegmentIdCount) {
  Set<MockId> idsToTtlUpdate = new HashSet<>();
  // return the first half of ids in the map
  int needed = referenceIndex.size() / 2;
  int current = 0;
  for (MockId id : referenceIndex.keySet()) {
    if (current >= needed) {
      break;
    }
    idsToTtlUpdate.add(id);
    current++;
  }
  // generate some ids for ttl update
  idsToTtlUpdate.addAll(generateIds(referenceIndex, outOfSegmentIdCount));
  return idsToTtlUpdate;
}
 
源代码7 项目: scava   文件: BTreeMapSubSetTest.java
/**
 * Returns a new set of given size containing consecutive
 * Integers 0 ... n.
 */
private NavigableSet<Integer> populatedSet(int n) {
    NavigableSet<Integer> q =
        newNavigableSet();
    assertTrue(q.isEmpty());

    for (int i = n-1; i >= 0; i-=2)
        assertTrue(q.add(new Integer(i)));
    for (int i = (n & 1); i < n; i+=2)
        assertTrue(q.add(new Integer(i)));
    assertTrue(q.add(new Integer(-n)));
    assertTrue(q.add(new Integer(n)));
    NavigableSet s = q.subSet(new Integer(0), true, new Integer(n), false);
    assertFalse(s.isEmpty());
    assertEquals(n, s.size());
    return s;
}
 
源代码8 项目: openjdk-jdk9   文件: TreeSetTest.java
/**
 * Subsets of subsets subdivide correctly
 */
public void testRecursiveSubSets() throws Exception {
    int setSize = expensiveTests ? 1000 : 100;
    Class cl = TreeSet.class;

    NavigableSet<Integer> set = newSet(cl);
    bs = new BitSet(setSize);

    populate(set, setSize);
    check(set,                 0, setSize - 1, true);
    check(set.descendingSet(), 0, setSize - 1, false);

    mutateSet(set, 0, setSize - 1);
    check(set,                 0, setSize - 1, true);
    check(set.descendingSet(), 0, setSize - 1, false);

    bashSubSet(set.subSet(0, true, setSize, false),
               0, setSize - 1, true);
}
 
@Test
public void testGetGet_SingleCellFieldDefinition() {
    FieldDefinition fieldDef = new FieldDefinition("fieldname", "cf:qualifier", ValueSource.VALUE, "int");
    
    DefaultResultToSolrMapper resultMapper = new DefaultResultToSolrMapper("index-name", Lists.newArrayList(fieldDef),
                    Collections.<DocumentExtractDefinition>emptyList());
    Get get = resultMapper.getGet(ROW);
    
    assertArrayEquals(ROW, get.getRow());
    assertEquals(1, get.getFamilyMap().size());
    
    assertTrue(get.getFamilyMap().containsKey(Bytes.toBytes("cf")));
    NavigableSet<byte[]> qualifiers = get.getFamilyMap().get(Bytes.toBytes("cf"));
    assertEquals(1, qualifiers.size());
    assertTrue(qualifiers.contains(Bytes.toBytes("qualifier")));
}
 
源代码10 项目: j2objc   文件: ConcurrentSkipListSubSetTest.java
/**
 * headSet returns set with keys in requested range
 */
public void testHeadSetContents() {
    NavigableSet set = set5();
    SortedSet sm = set.headSet(four);
    assertTrue(sm.contains(one));
    assertTrue(sm.contains(two));
    assertTrue(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, set.size());
    assertEquals(four, set.first());
}
 
源代码11 项目: skywalking   文件: MeterBuilder.java
/**
 * Build the histogram
 * @return return histogram if support
 */
public static Optional<Histogram> buildHistogram(MeterId meterId, boolean supportsAggregablePercentiles,
                                                 DistributionStatisticConfig distributionStatisticConfig,
                                                 boolean useNanoTime) {
    if (!distributionStatisticConfig.isPublishingHistogram()) {
        return Optional.empty();
    }

    final NavigableSet<Double> buckets = distributionStatisticConfig.getHistogramBuckets(supportsAggregablePercentiles);
    final List<Double> steps = buckets.stream().sorted(Double::compare)
        .map(t -> useNanoTime ? TimeUtils.nanosToUnit(t, TimeUnit.MILLISECONDS) : t).collect(Collectors.toList());

    final Histogram.Builder histogramBuilder = MeterFactory.histogram(
        meterId.copyTo(meterId.getName() + "_histogram", MeterId.MeterType.HISTOGRAM)).steps(steps);
    final Double minimumExpectedValueAsDouble = distributionStatisticConfig.getMinimumExpectedValueAsDouble();
    if (minimumExpectedValueAsDouble != null) {
        histogramBuilder.minValue(useNanoTime ?
            TimeUtils.nanosToUnit(minimumExpectedValueAsDouble, TimeUnit.MILLISECONDS) : minimumExpectedValueAsDouble);
    }
    return Optional.of(histogramBuilder.build());
}
 
源代码12 项目: openjdk-jdk9   文件: TreeSetTest.java
void mutateSet(NavigableSet<Integer> set, int min, int max) {
    int size = set.size();
    int rangeSize = max - min + 1;

    // Remove a bunch of entries directly
    for (int i = 0, n = rangeSize / 2; i < n; i++) {
        remove(set, min - 5 + rnd.nextInt(rangeSize + 10));
    }

    // Remove a bunch of entries with iterator
    for (Iterator<Integer> it = set.iterator(); it.hasNext(); ) {
        if (rnd.nextBoolean()) {
            bs.clear(it.next());
            it.remove();
        }
    }

    // Add entries till we're back to original size
    while (set.size() < size) {
        int element = min + rnd.nextInt(rangeSize);
        assertTrue(element >= min && element <= max);
        put(set, element);
    }
}
 
源代码13 项目: hbase   文件: ReversedMobStoreScanner.java
ReversedMobStoreScanner(HStore store, ScanInfo scanInfo, Scan scan, NavigableSet<byte[]> columns,
    long readPt) throws IOException {
  super(store, scanInfo, scan, columns, readPt);
  cacheMobBlocks = MobUtils.isCacheMobBlocks(scan);
  rawMobScan = MobUtils.isRawMobScan(scan);
  readEmptyValueOnMobCellMiss = MobUtils.isReadEmptyValueOnMobCellMiss(scan);
  if (!(store instanceof HMobStore)) {
    throw new IllegalArgumentException("The store " + store + " is not a HMobStore");
  }
  mobStore = (HMobStore) store;
  this.referencedMobCells = new ArrayList<>();
}
 
/**
 * isEmpty is true before add, false after
 */
public void testEmpty() {
    NavigableSet q = set0();
    assertTrue(q.isEmpty());
    q.add(new Integer(1));
    assertFalse(q.isEmpty());
    q.add(new Integer(2));
    q.pollFirst();
    q.pollFirst();
    assertTrue(q.isEmpty());
}
 
private NavigableSet<KafkaAssignerDiskUsageDistributionGoal.ReplicaWrapper> sortedReplicaAscend(Broker broker) {
  NavigableSet<KafkaAssignerDiskUsageDistributionGoal.ReplicaWrapper> sortedReplicas = new TreeSet<>();
  for (Replica r : broker.replicas()) {
    sortedReplicas.add(new KafkaAssignerDiskUsageDistributionGoal.ReplicaWrapper(r, r.load().expectedUtilizationFor(DISK)));
  }
  return sortedReplicas;
}
 
源代码16 项目: j2objc   文件: TreeSubSetTest.java
/**
 * addAll of a collection with null elements throws NPE
 */
public void testDescendingAddAll2() {
    NavigableSet q = dset0();
    Integer[] ints = new Integer[SIZE];
    try {
        q.addAll(Arrays.asList(ints));
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
源代码17 项目: j2objc   文件: TreeSubSetTest.java
/**
 * addAll(null) throws NPE
 */
public void testAddAll1() {
    NavigableSet q = set0();
    try {
        q.addAll(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
源代码18 项目: j2objc   文件: ConcurrentSkipListSubSetTest.java
/**
 * containsAll(c) is true when c contains a subset of elements
 */
public void testContainsAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = set0();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        p.add(new Integer(i));
    }
    assertTrue(p.containsAll(q));
}
 
源代码19 项目: beam   文件: InMemoryTimerInternals.java
private NavigableSet<TimerData> timersForDomain(TimeDomain domain) {
  switch (domain) {
    case EVENT_TIME:
      return watermarkTimers;
    case PROCESSING_TIME:
      return processingTimers;
    case SYNCHRONIZED_PROCESSING_TIME:
      return synchronizedProcessingTimers;
    default:
      throw new IllegalArgumentException("Unexpected time domain: " + domain);
  }
}
 
源代码20 项目: j2objc   文件: TreeSubSetTest.java
/**
 * containsAll(c) is true when c contains a subset of elements
 */
public void testContainsAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = set0();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        p.add(new Integer(i));
    }
    assertTrue(p.containsAll(q));
}
 
源代码21 项目: phoenix-tephra   文件: TransactionProcessor.java
/**
 * Ensures that family delete markers are present in the columns requested for any get operation.
 * @param get The original get request
 * @return The modified get request with the family delete qualifiers represented
 */
private Get projectFamilyDeletes(Get get) {
  for (Map.Entry<byte[], NavigableSet<byte[]>> entry : get.getFamilyMap().entrySet()) {
    NavigableSet<byte[]> columns = entry.getValue();
    // wildcard scans will automatically include the delete marker, so only need to add it when we have
    // explicit columns listed
    if (columns != null && !columns.isEmpty()) {
      get.addColumn(entry.getKey(), TxConstants.FAMILY_DELETE_QUALIFIER);
    }
  }
  return get;
}
 
源代码22 项目: openjdk-jdk9   文件: TreeSubSetTest.java
/**
 * clear removes all elements
 */
public void testClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertTrue(q.add(new Integer(1)));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
/**
 * lower returns preceding element
 */
public void testLower() {
    NavigableSet q = set5();
    Object e1 = q.lower(three);
    assertEquals(two, e1);

    Object e2 = q.lower(six);
    assertEquals(five, e2);

    Object e3 = q.lower(one);
    assertNull(e3);

    Object e4 = q.lower(zero);
    assertNull(e4);
}
 
源代码24 项目: jdk8u-jdk   文件: EmptyNavigableSet.java
/**
 * Tests that contains requires Comparable
 */
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testContainsRequiresComparable(String description, NavigableSet<?> navigableSet) {
    assertThrows(() -> {
        navigableSet.contains(new Object());
    },
        ClassCastException.class,
        description + ": Compareable should be required");
}
 
源代码25 项目: codebuff   文件: Synchronized.java
@Override
public NavigableSet<E> descendingSet() {
  synchronized (mutex) {
    if (descendingSet == null) {
      NavigableSet<E> dS = Synchronized.navigableSet(delegate().descendingSet(), mutex);
      descendingSet = dS;
      return dS;
    }
    return descendingSet;
  }
}
 
源代码26 项目: codebuff   文件: Sets.java
@Override
public NavigableSet<E> descendingSet() {
  UnmodifiableNavigableSet<E> result = descendingSet;
  if (result == null) {
    result = descendingSet = new UnmodifiableNavigableSet<E>(delegate.descendingSet());
    result.descendingSet = this;
  }
  return result;
}
 
/**
 * @throws ClassCastException {@inheritDoc}
 * @throws NullPointerException if {@code fromElement} or
 *         {@code toElement} is null
 * @throws IllegalArgumentException {@inheritDoc}
 */
public NavigableSet<E> subSet(E fromElement,
                              boolean fromInclusive,
                              E toElement,
                              boolean toInclusive) {
    return new ConcurrentSkipListSet<E>
        (m.subMap(fromElement, fromInclusive,
                  toElement,   toInclusive));
}
 
源代码28 项目: codebuff   文件: TreeMultimap.java
/**
 * @since 14.0 (present with return type {@code SortedSet} since 2.0)
 */

@Override
@GwtIncompatible // NavigableSet
public NavigableSet<V> get(@Nullable K key) {
  return (NavigableSet<V>) super.get(key);
}
 
/**
 * add(null) throws NPE
 */
public void testDescendingAddNull() {
    try {
        NavigableSet q = dset0();
        q.add(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
源代码30 项目: j2objc   文件: ConcurrentSkipListSubSetTest.java
/**
 * Returns a new set of first 5 ints.
 */
private NavigableSet set5() {
    ConcurrentSkipListSet q = new ConcurrentSkipListSet();
    assertTrue(q.isEmpty());
    q.add(one);
    q.add(two);
    q.add(three);
    q.add(four);
    q.add(five);
    q.add(zero);
    q.add(seven);
    NavigableSet s = q.subSet(one, true, seven, false);
    assertEquals(5, s.size());
    return s;
}
 
 类所在包
 同包方法