当前位置: 首页>>代码示例>>Java>>正文


Java NavigableSet类代码示例

本文整理汇总了Java中java.util.NavigableSet的典型用法代码示例。如果您正苦于以下问题:Java NavigableSet类的具体用法?Java NavigableSet怎么用?Java NavigableSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NavigableSet类属于java.util包,在下文中一共展示了NavigableSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testheadSetRanges

import java.util.NavigableSet; //导入依赖的package包/类
@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 expansion
    assertThrowsIAE(() -> {
        ns.headSet(BigInteger.ONE, true);
    },
        description + ": Expansion should not be allowed");

    // much smaller
    subSet.headSet(isDescending(subSet) ? BigInteger.TEN : BigInteger.ZERO, true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:EmptyNavigableSet.java

示例2: testDescendingKeySetDescendingIteratorOrder

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * descending iterator of descendingKeySet is ordered
 */
public void testDescendingKeySetDescendingIteratorOrder() {
    TreeMap map = map5();
    NavigableSet s = map.descendingKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TreeMapTest.java

示例3: testNavigableSubSet

import java.util.NavigableSet; //导入依赖的package包/类
public void testNavigableSubSet() {
  for (List<Integer> contents : SAMPLE_INPUTS) {
    for (int i = 0; i < 10; i++) {
      for (int j = i + 1; j < 10; j++) {
        for (boolean fromInclusive : ImmutableList.of(true, false)) {
          for (boolean toInclusive : ImmutableList.of(true, false)) {
            NavigableSet<Integer> filterSubset = filter(
                createUnfiltered(contents).subSet(i, fromInclusive, j, toInclusive), EVEN);
            NavigableSet<Integer> subsetFilter = filter(createUnfiltered(contents), EVEN)
                .subSet(i, fromInclusive, j, toInclusive);
            assertEquals(filterSubset, subsetFilter);
          }
        }
      }
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:FilteredCollectionsTest.java

示例4: testIteratorRemove

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * iterator.remove removes current element
 */
public void testIteratorRemove() {
    final NavigableSet q = set0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));

    Iterator it = q.iterator();
    it.next();
    it.remove();

    it = q.iterator();
    assertEquals(it.next(), new Integer(2));
    assertEquals(it.next(), new Integer(3));
    assertFalse(it.hasNext());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentSkipListSubSetTest.java

示例5: testDescendingIterator

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * iterator iterates through all elements
 */
public void testDescendingIterator() {
    NavigableSet q = populatedSet(SIZE);
    int i = 0;
    Iterator it = q.iterator();
    while (it.hasNext()) {
        assertTrue(q.contains(it.next()));
        ++i;
    }
    assertEquals(i, SIZE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentSkipListSubSetTest.java

示例6: addColumn

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * Get the column from the specified family with the specified qualifier.
 * <p>
 * Overrides previous calls to addFamily for this family.
 * @param family family name
 * @param qualifier column qualifier
 * @return this
 */
public Scan addColumn(byte [] family, byte [] qualifier) {
  NavigableSet<byte []> set = familyMap.get(family);
  if(set == null) {
    set = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
  }
  if (qualifier == null) {
    qualifier = HConstants.EMPTY_BYTE_ARRAY;
  }
  set.add(qualifier);
  familyMap.put(family, set);
  return this;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:Scan.java

示例7: testContainsAll

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentSkipListSubSetTest.java

示例8: testPollFirst

import java.util.NavigableSet; //导入依赖的package包/类
public void testPollFirst() {
  for (List<Integer> contents : SAMPLE_INPUTS) {
    NavigableSet<Integer> filtered = filter(createUnfiltered(contents), EVEN);
    NavigableSet<Integer> unfiltered = createUnfiltered(filtered);

    assertEquals(unfiltered.pollFirst(), filtered.pollFirst());
    assertEquals(unfiltered, filtered);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:FilteredCollectionsTest.java

示例9: standardSubSet

import java.util.NavigableSet; //导入依赖的package包/类
/**
 * A sensible definition of {@link #subSet(Object, boolean, Object, boolean)} in terms of the
 * {@code headSet} and {@code tailSet} methods. In many cases, you may wish to override
 * {@link #subSet(Object, boolean, Object, boolean)} to forward to this implementation.
 */
@Beta
protected NavigableSet<E> standardSubSet(
    E fromElement,
    boolean fromInclusive,
    E toElement,
    boolean toInclusive) {
  return tailSet(fromElement, fromInclusive).headSet(toElement, toInclusive);
}
 
开发者ID:s-store,项目名称:s-store,代码行数:14,代码来源:ForwardingNavigableSet.java

示例10: demoNavigableSetRemove

import java.util.NavigableSet; //导入依赖的package包/类
private static void demoNavigableSetRemove(NavigableSet<Integer> set) {
    System.out.println("set: " + set);
    try {
        for (int i : set) {
            System.out.println(i);
            System.out.println("Calling set.remove(2)...");
            set.remove(2);
        }
    } catch (Exception ex) {
        System.out.println(ex.getClass().getName());
    }
    System.out.println("set: " + set);
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:14,代码来源:Chapter07Concurrency02.java

示例11: removeMonitors

import java.util.NavigableSet; //导入依赖的package包/类
private void removeMonitors(long limit) {
    Consumer<ClusterAddress> doRemove = node -> {
        if (DEBUG) {
            log.debug("Stopped monitoring [node={}]", node);
        }

        monitors.remove(node);
    };

    NavigableSet<ClusterAddress> allSorted = new TreeSet<>(allNodes);

    // Nodes that are before the local node in the ring.
    List<ClusterAddress> toRemove = allSorted.headSet(localNode, false).stream()
        .filter(monitors::containsKey)
        .limit(limit)
        .collect(toList());

    toRemove.forEach(doRemove);

    long removeMore = limit - toRemove.size();

    if (removeMore > 0) {
        allSorted.tailSet(localNode, false).stream()
            .filter(monitors::containsKey)
            .limit(limit)
            .forEach(doRemove);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:29,代码来源:DefaultFailureDetector.java

示例12: testToSubchartsDeep

import java.util.NavigableSet; //导入依赖的package包/类
@Test
public void testToSubchartsDeep() throws IOException {
  final String input = "wordpress/charts/mariadb/charts/frobnicator/templates/foo.yaml";
  final NavigableSet<String> output = StreamOrientedChartLoader.toSubcharts(input);
  assertNotNull(output);
  assertEquals(2, output.size());
  assertEquals("wordpress/charts/mariadb", output.first());
  assertEquals("wordpress/charts/mariadb/charts/frobnicator", output.last());
      
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:11,代码来源:TestStreamOrientedChartLoader.java

示例13: create

import java.util.NavigableSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <E> NavigableSet<E> create() {
  TestSet<E> inner =
      new TestSet<E>(new TreeSet<E>((Comparator<E>) Ordering.natural().nullsFirst()), null);
  NavigableSet<E> outer = Synchronized.navigableSet(inner, null);
  inner.mutex = outer;
  return outer;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:SynchronizedNavigableSetTest.java

示例14: subSet

import java.util.NavigableSet; //导入依赖的package包/类
@Override
public NavigableSet<E> subSet(
    E fromElement,
    boolean fromInclusive,
    E toElement,
    boolean toInclusive) {
  return unmodifiableNavigableSet(delegate.subSet(
      fromElement,
      fromInclusive,
      toElement,
      toInclusive));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:13,代码来源:Sets.java

示例15: getNextRow

import java.util.NavigableSet; //导入依赖的package包/类
private Cell getNextRow(final Cell key,
    final NavigableSet<Cell> set) {
  Cell result = null;
  SortedSet<Cell> tail = key == null? set: set.tailSet(key);
  // Iterate until we fall into the next row; i.e. move off current row
  for (Cell cell: tail) {
    if (comparator.compareRows(cell, key) <= 0)
      continue;
    // Note: Not suppressing deletes or expired cells.  Needs to be handled
    // by higher up functions.
    result = cell;
    break;
  }
  return result;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:DefaultMemStore.java


注:本文中的java.util.NavigableSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。