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