本文整理汇总了Java中java.util.TreeMap.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMap.isEmpty方法的具体用法?Java TreeMap.isEmpty怎么用?Java TreeMap.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkLocalityRelaxationConflict
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* ContainerRequests with locality relaxation cannot be made at the same
* priority as ContainerRequests without locality relaxation.
*/
private void checkLocalityRelaxationConflict(Priority priority,
Collection<String> locations, boolean relaxLocality) {
Map<String, TreeMap<Resource, ResourceRequestInfo>> remoteRequests =
this.remoteRequestsTable.get(priority);
if (remoteRequests == null) {
return;
}
// Locality relaxation will be set to relaxLocality for all implicitly
// requested racks. Make sure that existing rack requests match this.
for (String location : locations) {
TreeMap<Resource, ResourceRequestInfo> reqs =
remoteRequests.get(location);
if (reqs != null && !reqs.isEmpty()) {
boolean existingRelaxLocality =
reqs.values().iterator().next().remoteRequest.getRelaxLocality();
if (relaxLocality != existingRelaxLocality) {
throw new InvalidContainerRequestException("Cannot submit a "
+ "ContainerRequest asking for location " + location
+ " with locality relaxation " + relaxLocality + " when it has "
+ "already been requested with locality relaxation " + existingRelaxLocality);
}
}
}
}
示例2: reportConsumerRunningInfo
import java.util.TreeMap; //导入方法依赖的package包/类
public void reportConsumerRunningInfo(final String consumerGroup) throws InterruptedException,
MQBrokerException, RemotingException, MQClientException {
ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(consumerGroup);
TreeMap<String, ConsumerRunningInfo> infoMap = new TreeMap<String, ConsumerRunningInfo>();
for (Connection c : cc.getConnectionSet()) {
String clientId = c.getClientId();
if (c.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
continue;
}
try {
ConsumerRunningInfo info =
defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false);
infoMap.put(clientId, info);
} catch (Exception e) {
}
}
if (!infoMap.isEmpty()) {
this.monitorListener.reportConsumerRunningInfo(infoMap);
}
}
示例3: loadFromRealData
import java.util.TreeMap; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
TreeMap<String, AdjustWord> map = new TreeMap<>();
for (String url : resourceUrls) {
MynlpResource resource = environment.getMynlpResourceFactory().load(url);
try (CharSourceLineReader reader = resource.openLineReader()) {
while (reader.hasNext()) {
String line = reader.next();
AdjustWord adjustWord = AdjustWord.parse(line
);
map.put(adjustWord.path, adjustWord);
}
}
}
if (map.isEmpty()) {
return;
}
this.doubleArrayTrie = new DoubleArrayTrieBuilder<AdjustWord>().build(map);
}
示例4: getNewModes
import java.util.TreeMap; //导入方法依赖的package包/类
Map<String,String> getNewModes() {
if (newModes == null) {
return null;
}
TreeMap<String,String> copy = new TreeMap<String,String>(newModes);
if (existingModes != null) {
copy.keySet().removeAll(existingModes);
}
return copy.isEmpty() ? null : copy;
}
示例5: isAllEmpty
import java.util.TreeMap; //导入方法依赖的package包/类
private static boolean isAllEmpty(Collection<TreeMap<Double, Double>> coll) {
for(TreeMap<?,?> map : coll) {
if (!map.isEmpty())
return false;
}
return true;
}
示例6: getCurrentAppUsingUsageStats
import java.util.TreeMap; //导入方法依赖的package包/类
@Nullable
public static String getCurrentAppUsingUsageStats(Context context) {
try {
if (Build.VERSION.SDK_INT >= 21) {
// Although the UsageStatsManager was added in API 21, the
// constant to specify it wasn't added until API 22.
// So we use the value of that constant on API 21.
String usageStatsServiceString;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
usageStatsServiceString = (atLeastAPI(22)) ? Context.USAGE_STATS_SERVICE : "usagestats";
} else {
usageStatsServiceString = "usagestats";
}
@SuppressWarnings("WrongConstant")
UsageStatsManager usm = (UsageStatsManager) context.getSystemService(usageStatsServiceString);
long time = System.currentTimeMillis();
List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 1000, time);
if (appList != null && appList.size() > 0) {
TreeMap<Long, UsageStats> mySortedMap = new TreeMap<>();
for (UsageStats usageStats : appList) {
mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
}
if (!mySortedMap.isEmpty()) {
return mySortedMap.get(mySortedMap.lastKey()).getPackageName();
}
}
}
} catch (Exception e) {
// Ignore exceptions to allow the user to determine if it
// works him/herself
}
return null;
}
示例7: selectInterestingEntryWithEffect
import java.util.TreeMap; //导入方法依赖的package包/类
static SimpleEntry<ConditionDirectionPair, TreeMap<Effect, Double>> selectInterestingEntryWithEffect(TreeMap<ConditionDirectionPair, TreeMap<Effect, Double>> entries, Effect effect)
{
TreeMap<ConditionDirectionPair, TreeMap<Effect, Double>> entriesclone = new TreeMap<ConditionDirectionPair, TreeMap<Effect, java.lang.Double>>();
//filter knowledge
for(ConditionDirectionPair cdp : entries.keySet())
{
for(Entry<Effect, Double> e : entries.get(cdp).entrySet())
{
if(e.getKey().equals(effect))
{
TreeMap<Effect,Double> tmp = new TreeMap<Effect,Double>();
tmp.put(e.getKey(),e.getValue());
entriesclone.put(cdp,tmp);
}
}
/*if(entries.get(cdp).keySet().contains(effect))
{
entriesclone.put(cdp,entries.get(cdp));
}*/
}
if(entriesclone.isEmpty())
return null;
return selectInterestingEntry(entriesclone);
}
示例8: checkConditions
import java.util.TreeMap; //导入方法依赖的package包/类
private boolean checkConditions(GlobalCoarse playerPos, TreeMap<Effect, Double> effects){
System.out.println(" --------------------------------");
System.out.println(" CHECKCONDITIONS IS INVOKED WITH:");
System.out.println(" (" + playerPos + "," + effects);
if (goal.hasEffect() && !goal.getEffect().getType().equals(ActionEffect.PROGRESS))
{
//System.out.println("HO "+goal.getEffect());
if(!effects.isEmpty())
System.out.println(" " + effects.firstEntry().getKey() + " =? " + goal.getEffect());
if (effects.containsKey(goal.getEffect())){
System.out.println(" CHECKCONDITIONS RETURNS: " + true);
return true;
}
else{
System.out.println(" CHECKCONDITIONS RETURNS: " + false);
System.out.println(" ---------------------------------");
return false;
}
}
else{
System.out.println("");
System.out.println("DISTANCE: " + playerPos.distance(goal.getPosition()));
if(playerPos.distance(goal.getPosition())<=1){ //TODO: the position of the target sprite should be checked!
System.out.println(" CHECKCONDITIONS RETURNS: " + true);
System.out.println(" ---------------------------------");
return true;
}
else{
System.out.println(" CHECKCONDITIONS RETURNS: " + false);
System.out.println(" ---------------------------------");
return false;
}
}
}
示例9: mergeSorted
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* Merges already-sorted sections, reading one value from each dex into memory
* at a time.
*/
public final void mergeSorted() {
TableOfContents.Section[] sections = new TableOfContents.Section[dexes.length];
Dex.Section[] dexSections = new Dex.Section[dexes.length];
int[] offsets = new int[dexes.length];
int[] indexes = new int[dexes.length];
// values contains one value from each dex, sorted for fast retrieval of
// the smallest value. The list associated with a value has the indexes
// of the dexes that had that value.
TreeMap<T, List<Integer>> values = new TreeMap<T, List<Integer>>();
for (int i = 0; i < dexes.length; i++) {
sections[i] = getSection(dexes[i].getTableOfContents());
dexSections[i] = sections[i].exists() ? dexes[i].open(sections[i].off) : null;
// Fill in values with the first value of each dex.
offsets[i] = readIntoMap(
dexSections[i], sections[i], indexMaps[i], indexes[i], values, i);
}
getSection(contentsOut).off = out.getPosition();
int outCount = 0;
while (!values.isEmpty()) {
Map.Entry<T, List<Integer>> first = values.pollFirstEntry();
for (Integer dex : first.getValue()) {
updateIndex(offsets[dex], indexMaps[dex], indexes[dex]++, outCount);
// Fetch the next value of the dexes we just polled out
offsets[dex] = readIntoMap(dexSections[dex], sections[dex],
indexMaps[dex], indexes[dex], values, dex);
}
write(first.getKey());
outCount++;
}
getSection(contentsOut).size = outCount;
}
示例10: storeGroupSelection
import java.util.TreeMap; //导入方法依赖的package包/类
private boolean storeGroupSelection(TableViewer tableViewer, TreeMap<Integer, List<List<Integer>>> groupSelectionMap){
boolean retVal=false;
List<List<Integer>> grpList = new ArrayList<>();
List<Integer> selectionList = new ArrayList<>();
TableItem[] items = tableViewer.getTable().getItems();
for (TableItem tableItem : items) {
Button button = (Button) tableItem.getData(GROUP_CHECKBOX);
if(button.getSelection()){
selectionList.add(tableViewer.getTable().indexOf(tableItem));
}
}
if (groupSelectionMap.isEmpty()) {
grpList.add(selectionList);
groupSelectionMap.put(0, grpList);
retVal=true;
} else {
if (FilterHelper.INSTANCE.validateUserGroupSelection(groupSelectionMap, selectionList)) {
if(FilterHelper.INSTANCE.isColumnModifiable(groupSelectionMap, selectionList)){
retVal=true;
}else{
grpList.add(selectionList);
Map<Integer, List<List<Integer>>> tempMap = new TreeMap<>();
tempMap.putAll(groupSelectionMap);
groupSelectionMap.clear();
groupSelectionMap.put(0, grpList);
for (int i = 0; i < tempMap.size(); i++) {
groupSelectionMap.put(i + 1, tempMap.get(i));
}
retVal=true;
FilterHelper.INSTANCE.rearrangeGroups(groupSelectionMap, selectionList);
}
}
}
return retVal;
}
示例11: take
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* Remove a version tag from the map.
*/
public Map.Entry<VersionTag, T> take() {
if (tombstoneMap.isEmpty()) {
// if there are no more entries, return null;
return null;
} else {
// Otherwise, look at all of the members and find the tag with the
// lowest timestamp.
long lowestTimestamp = Long.MAX_VALUE;
TreeMap<VersionTag, T> lowestMap = null;
for (TreeMap<VersionTag, T> memberMap : tombstoneMap.values()) {
VersionTag firstTag = memberMap.firstKey();
long stamp = firstTag.getVersionTimeStamp();
if (stamp < lowestTimestamp) {
lowestTimestamp = stamp;
lowestMap = memberMap;
}
}
if (lowestMap == null) {
return null;
}
// Remove the lowest entry
Entry<VersionTag, T> result = lowestMap.firstEntry();
lowestMap.remove(result.getKey());
if (lowestMap.isEmpty()) {
// if this is the last entry from a given member,
// the map for that member
tombstoneMap.remove(result.getKey().getMemberID());
}
return result;
}
}
示例12: loadFromRealData
import java.util.TreeMap; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
MynlpResource dictResource = environment.loadResource(coreDictSetting);
TreeMap<String, NatureAttribute> map = new TreeMap<>();
int maxFreq = 0;
try (CharSourceLineReader reader = dictResource.openLineReader()) {
while (reader.hasNext()) {
String line = reader.next();
String[] param = line.split("\\s");
NatureAttribute attribute = NatureAttribute.create(param);
map.put(param[0], attribute);
maxFreq += attribute.getTotalFrequency();
}
}
this.MAX_FREQUENCY = maxFreq;
if (map.isEmpty()) {
throw new RuntimeException("not found core dict file ");
}
this.trie = new DoubleArrayTrieBuilder().build(map);
}
示例13: loadFromRealData
import java.util.TreeMap; //导入方法依赖的package包/类
@Override
public void loadFromRealData() throws Exception {
TreeMap<String, NatureAttribute> map = new TreeMap<>();
Nature defaultNature = Nature.n;
for (String url : resourceUrls) {
MynlpResource resource = environment.getMynlpResourceFactory().load(url);
try (CharSourceLineReader reader = resource.openLineReader()) {
while (reader.hasNext()) {
String line = reader.next();
String[] params = line.split("\\s");
if (isNormalization) {
params[0] = normalizationString(params[0]);
}
int natureCount = (params.length - 1) / 2;
NatureAttribute attribute;
if (natureCount == 0) {
attribute = NatureAttribute.create1000(defaultNature);
} else {
attribute = NatureAttribute.create(params);
}
map.put(params[0], attribute);
}
}
}
if (map.isEmpty()) {
return;
}
dat = new DoubleArrayTrieBuilder<NatureAttribute>().build(map);
}
示例14: onDoneCapturingAllPhotos
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* We've finished taking pictures from all phone's cameras
*/
@Override
public void onDoneCapturingAllPhotos(TreeMap<String, byte[]> picturesTaken) {
if (picturesTaken != null && !picturesTaken.isEmpty()) {
showToast("Done capturing all photos!");
return;
}
showToast("No camera detected!");
}
示例15: getTargetName
import java.util.TreeMap; //导入方法依赖的package包/类
/**
* 根据分片原始数据计算hash值,然后从hashingMap获取目标数据名称
*
* @param hashingMap
* @param shardingValue
* @return
*/
private static String getTargetName(TreeMap<Integer, String> hashingMap, String shardingValue) {
if (hashingMap.isEmpty()) {
return null;
}
//计算hash值
int hashKey = getHashing(shardingValue);
//获取真实key,找比hashKey大或者等的key值,找不到则取最小的key
Integer realKey = hashingMap.ceilingKey(hashKey);
if (null == realKey) {
realKey = hashingMap.firstKey();
}
return hashingMap.get(realKey);
}