本文整理匯總了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();
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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) {}
}
示例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.");
}
示例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();
}
示例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;
}
示例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);
}
}