當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。