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


Java TreeMap.isEmpty方法代码示例

本文整理汇总了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);
        }
      }
    }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:AMRMClientImpl.java

示例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);
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:24,代码来源:MonitorService.java

示例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);
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:24,代码来源:CorrectionDictionary.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:HTMLIterator.java

示例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;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:CirculinearCurve2DUtils.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:screenfilter,代码行数:36,代码来源:CurrentAppMonitoringThread.java

示例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);
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:29,代码来源:VoiceKnowledgeManager.java

示例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;
		}
	}
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:36,代码来源:EffectChaining.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:40,代码来源:DexMerger.java

示例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;  
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:40,代码来源:FilterConditionsDialog.java

示例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;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:36,代码来源:OrderedTombstoneMap.java

示例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);
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:28,代码来源:CoreDictionary.java

示例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);

}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:41,代码来源:CustomDictionary.java

示例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!");
}
 
开发者ID:botyourbusiness,项目名称:android-camera2-secret-picture-taker,代码行数:12,代码来源:MainActivity.java

示例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);
}
 
开发者ID:ilifan,项目名称:smart-framework,代码行数:21,代码来源:ConsistentHashingMapping.java


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