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


Java NavigableMap类代码示例

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


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

示例1: testsForCheckedNavigableMap

import java.util.NavigableMap; //导入依赖的package包/类
public Test testsForCheckedNavigableMap() {
  return SortedMapTestSuiteBuilder.using(
      new TestStringSortedMapGenerator() {
        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
          NavigableMap<String, String> map = populate(new TreeMap<String, String>(), entries);
          return Collections.checkedNavigableMap(map, String.class, String.class);
        }
      })
      .named("checkedNavigableMap/TreeMap, natural")
      .withFeatures(
          MapFeature.GENERAL_PURPOSE,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION,
          MapFeature.RESTRICTS_KEYS,
          MapFeature.RESTRICTS_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForCheckedNavigableMap())
      .createTestSuite();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:24,代码来源:TestsForMapsInJavaUtil.java

示例2: locateRegions

import java.util.NavigableMap; //导入依赖的package包/类
@Override
public List<HRegionLocation> locateRegions(final TableName tableName,
    final boolean useCache, final boolean offlined) throws IOException {
  NavigableMap<HRegionInfo, ServerName> regions = MetaScanner.allTableRegions(this, tableName);
  final List<HRegionLocation> locations = new ArrayList<HRegionLocation>();
  for (HRegionInfo regionInfo : regions.keySet()) {
    RegionLocations list = locateRegion(tableName, regionInfo.getStartKey(), useCache, true);
    if (list != null) {
      for (HRegionLocation loc : list.getRegionLocations()) {
        if (loc != null) {
          locations.add(loc);
        }
      }
    }
  }
  return locations;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:ConnectionManager.java

示例3: testSubMapContents2

import java.util.NavigableMap; //导入依赖的package包/类
public void testSubMapContents2() {
    NavigableMap 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,代码来源:TreeSubMapTest.java

示例4: testTailMapRanges

import java.util.NavigableMap; //导入依赖的package包/类
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
public void testTailMapRanges(String description, NavigableMap navigableMap) {
    NavigableMap subMap = navigableMap.tailMap(BigInteger.ONE, true);

    // same subset
    subMap.tailMap(BigInteger.ONE, true);

    // slightly smaller
    NavigableMap ns = subMap.tailMap(BigInteger.ONE, false);

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

    // much smaller
    subMap.tailMap(isDescending(subMap) ? BigInteger.ZERO : BigInteger.TEN, false);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:EmptyNavigableMap.java

示例5: getProtocolVersion

import java.util.NavigableMap; //导入依赖的package包/类
public static int getProtocolVersion()
{
	if(WurstClient.INSTANCE.options.mc112x_compatibility == 2)
		return 340;
	else if(WurstClient.INSTANCE.options.mc112x_compatibility == 1)
		return 338;
	
	NavigableMap<Integer, String> protocols = WMinecraft.PROTOCOLS;
	
	// use default if using Wurst-Bot
	if(WurstBot.isEnabled())
		return protocols.lastKey();
	
	ServerData server = lastServer.getServerData();
	
	// use default if ping failed
	if(!server.pinged || server.pingToServer < 0)
		return protocols.lastKey();
	
	// use default if server protocol is not supported
	if(!protocols.containsKey(server.version))
		return protocols.lastKey();
	
	// use server protocol
	return server.version;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12-OF,代码行数:27,代码来源:ServerHook.java

示例6: testsForUnmodifiableNavigableMap

import java.util.NavigableMap; //导入依赖的package包/类
public Test testsForUnmodifiableNavigableMap() {
  return MapTestSuiteBuilder.using(
      new TestStringSortedMapGenerator() {
        @Override
        protected NavigableMap<String, String> create(Entry<String, String>[] entries) {
          return Collections.unmodifiableNavigableMap(populate(new TreeMap<>(), entries));
        }
      })
      .named("unmodifiableNavigableMap/TreeMap, natural")
      .withFeatures(
          MapFeature.ALLOWS_NULL_VALUES,
          CollectionFeature.KNOWN_ORDER,
          CollectionFeature.SERIALIZABLE,
          CollectionSize.ANY)
      .suppressing(suppressForUnmodifiableNavigableMap())
      .createTestSuite();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:TestsForMapsInJavaUtil.java

示例7: testRangesByUpperBound

import java.util.NavigableMap; //导入依赖的package包/类
public void testRangesByUpperBound() {
  for (Range<Integer> range1 : QUERY_RANGES) {
    for (Range<Integer> range2 : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range1);
      rangeSet.add(range2);

      NavigableMap<Cut<Integer>, Range<Integer>> expectedRangesByUpperBound = Maps.newTreeMap();
      for (Range<Integer> range : rangeSet.asRanges()) {
        expectedRangesByUpperBound.put(range.upperBound, range);
      }
      testNavigationAgainstExpected(expectedRangesByUpperBound,
          new TreeRangeSet.RangesByUpperBound<Integer>(rangeSet.rangesByLowerBound),
          CUTS_TO_TEST);
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:TreeRangeSetTest.java

示例8: testDescendingKeySet

import java.util.NavigableMap; //导入依赖的package包/类
public void testDescendingKeySet() {
  NavigableMap<String, Integer> map = create();
  NavigableSet<String> descendingKeySet = map.descendingKeySet();
  assertTrue(descendingKeySet instanceof SynchronizedNavigableSet);
  assertSame(
      mutex, ((SynchronizedNavigableSet<String>) descendingKeySet).mutex);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:SynchronizedNavigableMapTest.java

示例9: testTailMap_K_B

import java.util.NavigableMap; //导入依赖的package包/类
public void testTailMap_K_B() {
  NavigableMap<String, Integer> map = create();
  NavigableMap<String, Integer> subMap = map.tailMap("a", true);
  assertTrue(subMap instanceof SynchronizedNavigableMap);
  assertSame(
      mutex, ((SynchronizedNavigableMap<String, Integer>) subMap).mutex);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:SynchronizedNavigableMapTest.java

示例10: pollFirstEntry

import java.util.NavigableMap; //导入依赖的package包/类
public static <K, V, W extends Iterable<V>> Entry<K, V> pollFirstEntry(NavigableMap<K, W> map) {
    Entry<K, V> result = null;

    Iterator<Entry<K, W>> itE = map.entrySet().iterator();

    // For robustness, remove entry valueX sets
    while(itE.hasNext()) {
        Entry<K, W> e = itE.next();

        K k = e.getKey();
        Iterable<V> vs = e.getValue();

        Iterator<V> itV = vs.iterator();
        if(itV.hasNext()) {
            V v = itV.next();
            itV.remove();

            if(!itV.hasNext()) {
                itE.remove();
            }

            result = new SimpleEntry<>(k, v);
            break;
        } else {
            itE.remove();
            continue;
        }
    }

    return result;
}
 
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:32,代码来源:ProblemContainerNeighbourhoodAware.java

示例11: testDescendingPut1_NullPointerException

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

示例12: testContainsAll

import java.util.NavigableMap; //导入依赖的package包/类
/**
 * Tests that the containsAll method returns {@code false}.
 */
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
public void testContainsAll(String description, NavigableMap<?,?> navigableMap) {
    TreeMap treeMap = new TreeMap();
    treeMap.put("1", 1);
    treeMap.put("2", 2);
    treeMap.put("3", 3);

    assertFalse(navigableMap.equals(treeMap), "Should not contain any elements.");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:EmptyNavigableMap.java

示例13: toString

import java.util.NavigableMap; //导入依赖的package包/类
@Override
public String toString() {
  StringBuilder sb =
      new StringBuilder()
          .append("SizeConfigStrategy{groupedMap=")
          .append(groupedMap)
          .append(", sortedSizes=(");
  for (Map.Entry<Bitmap.Config, NavigableMap<Integer, Integer>> entry : sortedSizes.entrySet()) {
    sb.append(entry.getKey()).append('[').append(entry.getValue()).append("], ");
  }
  if (!sortedSizes.isEmpty()) {
    sb.replace(sb.length() - 2, sb.length(), "");
  }
  return sb.append(")}").toString();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SizeConfigStrategy.java

示例14: getStoreFiles

import java.util.NavigableMap; //导入依赖的package包/类
/**
 * @return Map of StoreFiles by column family
 */
private NavigableMap<byte[], List<Path>> getStoreFiles() {
  NavigableMap<byte[], List<Path>> allStoreFiles =
      new TreeMap<byte[], List<Path>>(Bytes.BYTES_COMPARATOR);
  for (Store store : getStores()) {
    Collection<StoreFile> storeFiles = store.getStorefiles();
    if (storeFiles == null) continue;
    List<Path> storeFileNames = new ArrayList<Path>();
    for (StoreFile storeFile : storeFiles) {
      storeFileNames.add(storeFile.getPath());
    }
    allStoreFiles.put(store.getFamily().getName(), storeFileNames);
  }
  return allStoreFiles;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:HRegion.java

示例15: decrementArrayOfSize

import java.util.NavigableMap; //导入依赖的package包/类
private void decrementArrayOfSize(int size, Class<?> arrayClass) {
  NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass);
  Integer current = sizes.get(size);
  if (current == null) {
    throw new NullPointerException(
        "Tried to decrement empty size" + ", size: " + size + ", this: " + this);
  }
  if (current == 1) {
    sizes.remove(size);
  } else {
    sizes.put(size, current - 1);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LruArrayPool.java


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