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


Java ConcurrentNavigableMap类代码示例

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


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

示例1: testGet_concurrent

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
public void testGet_concurrent() {
  assertTrue(ArbitraryInstances.get(BlockingDeque.class).isEmpty());
  assertTrue(ArbitraryInstances.get(BlockingQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(DelayQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(SynchronousQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(PriorityBlockingQueue.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ConcurrentMap.class).isEmpty());
  assertTrue(ArbitraryInstances.get(ConcurrentNavigableMap.class).isEmpty());
  ArbitraryInstances.get(Executor.class).execute(ArbitraryInstances.get(Runnable.class));
  assertNotNull(ArbitraryInstances.get(ThreadFactory.class));
  assertFreshInstanceReturned(
      BlockingQueue.class, BlockingDeque.class, PriorityBlockingQueue.class,
      DelayQueue.class, SynchronousQueue.class,
      ConcurrentMap.class, ConcurrentNavigableMap.class,
      AtomicReference.class, AtomicBoolean.class,
      AtomicInteger.class, AtomicLong.class, AtomicDouble.class);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:ArbitraryInstancesTest.java

示例2: getTableLocations

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * @param tableName
 * @return Map of cached locations for passed <code>tableName</code>
 */
private ConcurrentNavigableMap<byte[], RegionLocations>
  getTableLocations(final TableName tableName) {
  // find the map of cached locations for this table
  ConcurrentNavigableMap<byte[], RegionLocations> result;
  result = this.cachedRegionLocations.get(tableName);
  // if tableLocations for this table isn't built yet, make one
  if (result == null) {
    result = new CopyOnWriteArrayMap<>(Bytes.BYTES_COMPARATOR);
    ConcurrentNavigableMap<byte[], RegionLocations> old =
        this.cachedRegionLocations.putIfAbsent(tableName, result);
    if (old != null) {
      return old;
    }
  }
  return result;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:MetaCache.java

示例3: testDescendingPollLastEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testDescendingPollLastEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(m5, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(m4, e.getKey());
    map.put(m5, "E");
    e = map.pollLastEntry();
    assertEquals(m5, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(m3, e.getKey());
    map.remove(m2);
    e = map.pollLastEntry();
    assertEquals(m1, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollLastEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例4: resolveByUuid

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
@Override
public Optional<ServerAddress> resolveByUuid(UUID uuid) {
  Assert.notNull(uuid);
  if (circle.isEmpty()) {
    return Optional.empty();
  }
  Long hash = hashFunction.newHasher().putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits())
      .hash().asLong();
  if (!circle.containsKey(hash)) {
    ConcurrentNavigableMap<Long, ServerInstance> tailMap = circle.tailMap(hash);
    hash = tailMap.isEmpty() ? circle.firstKey() : tailMap.firstKey();
  }
  ServerInstance result = circle.get(hash);
  if (!currentServer.equals(result)) {
    return Optional.of(result.getServerAddress());
  } else {
    return Optional.empty();
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:20,代码来源:ConsistentClusterRoutingService.java

示例5: testDescendingPollFirstEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * pollFirstEntry returns entries in order
 */
public void testDescendingPollFirstEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m2, e.getKey());
    map.put(m1, "A");
    e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m3, e.getKey());
    map.remove(m4);
    e = map.pollFirstEntry();
    assertEquals(m5, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollFirstEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例6: tailMap

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
@Override
public ConcurrentNavigableMap<K, V> tailMap(K fromKey, boolean inclusive) {
  ArrayHolder<K, V> current = this.holder;
  int index = current.find(fromKey);

  if (!inclusive && index >= 0) {
    index++;
  } else if (index < 0) {
    index = -(index + 1);
  }
  return new CopyOnWriteArrayMap<>(
      this.keyComparator,
      new ArrayHolder<>(
          current.entries,
          index,
          current.endIndex,
          current.keyComparator,
          current.comparator));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:CopyOnWriteArrayMap.java

示例7: testEntrySet

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    ConcurrentNavigableMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentSkipListSubMapTest.java

示例8: putAllCollections

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
static void putAllCollections(Map<Class<?>, IntFunction<?>> map, Map<Class<?>, Function<?, ?>> unmodMap)
{
    safePut(map, ArrayList.class, ArrayList::new);
    safePut(map, HashSet.class, LinkedHashSet::new);
    safePut(map, Properties.class, x -> new Properties());
    safePut(map, Hashtable.class, Hashtable::new);

    safePut(map, Collection.class, ArrayList::new);
    safePut(map, Set.class, LinkedHashSet::new);
    safePut(map, List.class, ArrayList::new);
    safePut(map, SortedSet.class, x -> new TreeSet<>());
    safePut(map, Queue.class, x -> new ConcurrentLinkedQueue<>());
    safePut(map, Deque.class, x -> new ConcurrentLinkedDeque<>());
    safePut(map, BlockingQueue.class, x -> new LinkedBlockingQueue<>());
    safePut(map, BlockingDeque.class, x -> new LinkedBlockingDeque<>());


    safePut(map, HashMap.class, LinkedHashMap::new);
    safePut(map, LinkedHashMap.class, LinkedHashMap::new);
    safePut(map, ConcurrentHashMap.class, ConcurrentHashMap::new);

    safePut(map, Map.class, LinkedHashMap::new);
    safePut(map, ConcurrentMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, ConcurrentNavigableMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, SortedMap.class, i -> new TreeMap<>());
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:27,代码来源:YamlCollectionCreator.java

示例9: testPollFirstEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * pollFirstEntry returns entries in order
 */
public void testPollFirstEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(two, e.getKey());
    map.put(one, "A");
    e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(three, e.getKey());
    map.remove(four);
    e = map.pollFirstEntry();
    assertEquals(five, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollFirstEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例10: testPollLastEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testPollLastEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(four, e.getKey());
    map.put(five, "E");
    e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(three, e.getKey());
    map.remove(two);
    e = map.pollLastEntry();
    assertEquals(one, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollLastEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例11: testDescendingHeadMapContents

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * headMap returns map with keys in requested range
 */
public void testDescendingHeadMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.headMap(m4);
    assertTrue(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m1, k);
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(m4, map.firstKey());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ConcurrentSkipListSubMapTest.java

示例12: testSubMapContents2

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
public void testSubMapContents2() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.subMap(two, three);
    assertEquals(1, sm.size());
    assertEquals(two, sm.firstKey());
    assertEquals(two, sm.lastKey());
    assertFalse(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertFalse(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(two));
    assertEquals(4, map.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertSame(sm.remove(three), null);
    assertEquals(4, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例13: testDescendingEntrySet

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * entrySet contains all pairs
 */
public void testDescendingEntrySet() {
    ConcurrentNavigableMap map = dmap5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(m1) && e.getValue().equals("A")) ||
                   (e.getKey().equals(m2) && e.getValue().equals("B")) ||
                   (e.getKey().equals(m3) && e.getValue().equals("C")) ||
                   (e.getKey().equals(m4) && e.getValue().equals("D")) ||
                   (e.getKey().equals(m5) && e.getValue().equals("E")));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentSkipListSubMapTest.java

示例14: testDescendingReplace_NullPointerException

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * replace(null, x) throws NPE
 */
public void testDescendingReplace_NullPointerException() {
    try {
        ConcurrentNavigableMap c = dmap5();
        c.replace(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentSkipListSubMapTest.java

示例15: headMap

import java.util.concurrent.ConcurrentNavigableMap; //导入依赖的package包/类
/**
 * @throws ClassCastException {@inheritDoc}
 * @throws NullPointerException if {@code toKey} is null
 * @throws IllegalArgumentException {@inheritDoc}
 */
public ConcurrentNavigableMap<K,V> headMap(K toKey,
                                           boolean inclusive) {
    if (toKey == null)
        throw new NullPointerException();
    return new SubMap<K,V>
        (this, null, false, toKey, inclusive, false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ConcurrentSkipListMap.java


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