本文整理匯總了Java中java.util.NavigableMap.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigableMap.containsKey方法的具體用法?Java NavigableMap.containsKey怎麽用?Java NavigableMap.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.NavigableMap
的用法示例。
在下文中一共展示了NavigableMap.containsKey方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: matchExtensions
import java.util.NavigableMap; //導入方法依賴的package包/類
/**
* Match a set of strings of new types to be imported against the set of existing extensions
* based on package names and type names. This method returns a set of old extensions that
* are a subset of the new types based on the type names. For example, if you have an old
* extension com.foo.Bar and you import a new extension that is package name com.foo, then we
* will need to check that com.foo.Bar is inside com.foo and, if so, perform an upgrade.
*
* @param existing Existing set of extensions in the project
* @param newTypes New type(s) defined by the extension being imported
* @return A subset of the existing extensions that will need to be checked against the new
* extension to determine whether we are performing an upgrade or adding a fresh extension.
*/
private static Set<String> matchExtensions(NavigableMap<String, Set<String>> existing,
Set<String> newTypes) {
Set<String> results = new HashSet<>();
String packageName = getPackageName(newTypes.iterator().next());
if (existing.containsKey(packageName)) {
results.add(packageName);
}
NavigableMap<String, Set<String>> related = existing.tailMap(packageName, true);
for (String k : related.navigableKeySet()) {
if (!k.startsWith(packageName)) {
break; // no longer in the same package
}
results.add(k);
}
return results;
}
示例3: filter
import java.util.NavigableMap; //導入方法依賴的package包/類
@Override
public Entry filter(Entry entry) {
NavigableMap<byte[], Integer> scopes = entry.getKey().getScopes();
if (scopes == null || scopes.isEmpty()) {
return null;
}
ArrayList<Cell> cells = entry.getEdit().getCells();
int size = cells.size();
for (int i = size - 1; i >= 0; i--) {
Cell cell = cells.get(i);
// The scope will be null or empty if
// there's nothing to replicate in that WALEdit
if (!scopes.containsKey(cell.getFamily())
|| scopes.get(cell.getFamily()) == HConstants.REPLICATION_SCOPE_LOCAL) {
cells.remove(i);
}
}
if (cells.size() < size / 2) {
cells.trimToSize();
}
return entry;
}
示例4: getMsn
import java.util.NavigableMap; //導入方法依賴的package包/類
/**
* Returns message sequence number in the folder by its UID.
*
* @param uid - message UID.
* @return message sequence number.
* @throws FolderException if no message with given UID.
*/
@Override
public int getMsn(long uid) throws FolderException
{
NavigableMap<Long, FileInfo> messages = searchMails();
if (!messages.containsKey(uid))
{
throw new FolderException("No such message.");
}
return messages.headMap(uid, true).size();
}
示例5: testContainsKey_NullPointerException
import java.util.NavigableMap; //導入方法依賴的package包/類
/**
* containsKey(null) of nonempty map throws NPE
*/
public void testContainsKey_NullPointerException() {
NavigableMap c = map5();
try {
c.containsKey(null);
shouldThrow();
} catch (NullPointerException success) {}
}