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


Java TreeMap.lastKey方法代码示例

本文整理汇总了Java中java.util.TreeMap.lastKey方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMap.lastKey方法的具体用法?Java TreeMap.lastKey怎么用?Java TreeMap.lastKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.TreeMap的用法示例。


在下文中一共展示了TreeMap.lastKey方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Convert settings from the internal representation to the string representation used in the
 * preference storage.
 *
 * @param settings
 *         The map of settings to convert.
 * @param settingDescriptions
 *         The structure containing the {@link SettingsDescription} objects that will be used
 *         to convert the setting values.
 *
 * @return The settings converted to the string representation used in the preference storage.
 */
public static Map<String, String> convert(Map<String, Object> settings,
        Map<String, TreeMap<Integer, SettingsDescription>> settingDescriptions) {
    Map<String, String> serializedSettings = new HashMap<>();

    for (Entry<String, Object> setting : settings.entrySet()) {
        String settingName = setting.getKey();
        Object internalValue = setting.getValue();

        TreeMap<Integer, SettingsDescription> versionedSetting = settingDescriptions.get(settingName);
        Integer highestVersion = versionedSetting.lastKey();
        SettingsDescription settingDesc = versionedSetting.get(highestVersion);

        if (settingDesc != null) {
            String stringValue = settingDesc.toString(internalValue);

            serializedSettings.put(settingName, stringValue);
        } else {
            Timber.w("Settings.convert() called with a setting that should have been removed: %s", settingName);
        }
    }

    return serializedSettings;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:36,代码来源:Settings.java

示例2: testLastKey

import java.util.TreeMap; //导入方法依赖的package包/类
public void testLastKey()
{
	// create two random treemaps and retrieve their last keys
	TreeMap<Integer,Integer> tree1 = TreeMapFactory.getTree(TreeMapFactory.SIZE/2);
	Comparable<Integer> lastkey1 = (Comparable<Integer>)tree1.lastKey();
	
	TreeMap<Integer,Integer> tree2 = TreeMapFactory.getTree(TreeMapFactory.SIZE/2);
	Comparable<Integer> lastkey2 = (Comparable<Integer>)tree2.lastKey();
	
	// join them together and check the last key is correct
	tree1.putAll(tree2);
	
	if (lastkey1.compareTo((Integer)lastkey2) >= 0)
	{
		assertEquals(lastkey1, tree1.lastKey());
	}
	else
	{
		assertEquals(lastkey2, tree1.lastKey());
	}
	
	// put the largest Integer in and see if it's the last key
	tree1.put(new Integer(Integer.MAX_VALUE), null);
	assertEquals(new Integer(Integer.MAX_VALUE), tree1.lastKey());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:26,代码来源:TreeMapAPITest.java

示例3: isColumnModifiable

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Checks if column is modifiable.
 * 
 * @param groupSelectionMap
 *            the group selection map
 * @param selectionList
 *            the selection list
 * @return true, if is column modifiable
 */
public boolean isColumnModifiable(TreeMap<Integer,List<List<Integer>>> groupSelectionMap,List<Integer> selectionList){
	boolean retValue = false;
	for(int i=groupSelectionMap.lastKey();i>=0;i--){
		retValue=true;
		List<List<Integer>> groups = new ArrayList<>(groupSelectionMap.get(i));
		for (List<Integer> grp : groups) {
			if (ListUtils.intersection(selectionList, grp).size()>0) {
				retValue=false;
			}
	    }
	
		if(retValue){
			groupSelectionMap.get(i).add(selectionList);
			break;
		}
	}
	return retValue;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:28,代码来源:FilterHelper.java

示例4: rearrangeGroups

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Rearrange groups.
 * 
 * @param groupSelectionMap
 *            the group selection map
 * @param selectionList
 *            the selection list
 */
public void rearrangeGroups(TreeMap<Integer, List<List<Integer>>> groupSelectionMap,List<Integer> selectionList) {
	List<Integer> tempList = new ArrayList<>();
	int lastKey=groupSelectionMap.lastKey();
	for (int i = lastKey; i >= 0; i--) {
		List<List<Integer>> groups =groupSelectionMap.get(i);
		for (int j=0; j<=groups.size()-1;j++) {
			if (selectionList.size()< groups.get(j).size()&& 
					ListUtils.intersection(selectionList, groups.get(j)).size() > 0) {
				tempList.addAll(groups.get(j));
				groups.get(j).clear();
				groups.set(j,new ArrayList<Integer>(selectionList));					
				selectionList.clear();
				selectionList.addAll(tempList);
			}
			tempList.clear();
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:27,代码来源:FilterHelper.java

示例5: rearrangeGroupsAfterDeleteRow

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Rearrange groups after delete row.
 * 
 * @param groupSelectionMap
 *            the group selection map
 * @param selectionList
 *            the selection list
 * @return true, if successful
 */
public boolean rearrangeGroupsAfterDeleteRow(TreeMap<Integer, List<List<Integer>>> groupSelectionMap,
		List<Integer> selectionList) {
	boolean retValue = false;
	int lastKey = groupSelectionMap.lastKey();
	int count = 0;
	for (int i = lastKey; i >= 0; i--) {
		List<List<Integer>> groups = groupSelectionMap.get(i);
		for (int j = 0; j <= groups.size() - 1; j++) {
			if (selectionList.size() == groups.get(j).size() && ListUtils.isEqualList(selectionList, groups.get(j))) {
				count++;
				if (count >= 2) {
					retValue = true;
				}
			}
		}
	}
	return retValue;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:28,代码来源:FilterHelper.java

示例6: LinkDocHandler

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * コンストラクタ.
 * @param srcHandler OEntityDocHandler
 * @param tgtHandler OEntityDocHandler
 */
public LinkDocHandler(final EntitySetDocHandler srcHandler, final EntitySetDocHandler tgtHandler) {
    this.cellId = srcHandler.getCellId();
    this.boxId = srcHandler.getBoxId();
    this.nodeId = srcHandler.getNodeId();
    String srcType = srcHandler.getType();
    String srcId = srcHandler.getId();
    String tgtType = tgtHandler.getType();
    String tgtId = tgtHandler.getId();

    // ES 保存時の一意キー作成
    TreeMap<String, String> tm = new TreeMap<String, String>();
    tm.put(srcType, srcId);
    tm.put(tgtType, tgtId);

    this.ent1Type = tm.firstKey();
    this.ent2Type = tm.lastKey();
    this.ent1Key = tm.get(ent1Type);
    this.ent2Key = tm.get(ent2Type);
    this.id = this.createLinkId();
    long dateTime = new Date().getTime();
    this.published = dateTime;
    this.updated = dateTime;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:29,代码来源:LinkDocHandler.java

示例7: NtoNQueryParameter

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * コンストラクタ.
 * @param srcHandler OEntityDocHandler
 * @param targetSetName ターゲット側のEntitySet名
 * @param targetEntityTypeId ターゲット側のEntityTypeID
 */
public NtoNQueryParameter(
        final EntitySetDocHandler srcHandler,
        final String targetSetName,
        final String targetEntityTypeId) {
    String srcSetName = srcHandler.getType();
    String srcId = srcHandler.getId();

    TreeMap<String, String> tm = new TreeMap<String, String>();
    if (srcSetName.equals(UserDataODataProducer.USER_ODATA_NAMESPACE)) {
        tm.put(srcHandler.getEntityTypeId(), srcId);
        tm.put(targetEntityTypeId, "");
    } else {
        tm.put(srcSetName, srcId);
        tm.put(targetSetName, "");
    }
    this.t1 = tm.firstKey();
    this.t2 = tm.lastKey();
    this.k1 = tm.get(t1);
    this.k2 = tm.get(t2);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:27,代码来源:LinkDocHandler.java

示例8: toArray

import java.util.TreeMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Class<? extends Packet>[] toArray(Stream<Class<? extends Packet>> packets) {
    TreeMap<Integer, Class<? extends Packet>> map = new TreeMap<>();

    packets.forEach(packet -> {
        PacketInfo info = packet.getAnnotation(PacketInfo.class);
        map.put(info.id(), packet);
    });

    if (map.size() == 0) {
        return new Class[0];
    }

    Class<? extends Packet>[] array = new Class[map.lastKey() + 1];
    map.forEach((id, packet) -> array[id] = packet);

    return array;
}
 
开发者ID:dzikoysk,项目名称:UnknownPandaServer,代码行数:19,代码来源:ProtocolLoaderUtils.java

示例9: writeSettings

import java.util.TreeMap; //导入方法依赖的package包/类
private static void writeSettings(XmlSerializer serializer, Map<String, Object> prefs) throws IOException {

        for (Entry<String, TreeMap<Integer, SettingsDescription>> versionedSetting :
                GlobalSettings.SETTINGS.entrySet()) {

            String key = versionedSetting.getKey();
            String valueString = (String) prefs.get(key);
            TreeMap<Integer, SettingsDescription> versions = versionedSetting.getValue();
            Integer highestVersion = versions.lastKey();
            SettingsDescription setting = versions.get(highestVersion);
            if (setting == null) {
                // Setting was removed.
                continue;
            }

            if (valueString != null) {
                try {
                    writeKeyAndPrettyValueFromSetting(serializer, key, setting, valueString);
                } catch (InvalidSettingValueException e) {
                    Timber.w("Global setting \"%s\" has invalid value \"%s\" in preference storage. " +
                            "This shouldn't happen!", key, valueString);
                }
            } else {
                Timber.d("Couldn't find key \"%s\" in preference storage. Using default value.", key);
                writeKeyAndDefaultValueFromSetting(serializer, key, setting);
            }
        }
    }
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:29,代码来源:SettingsExporter.java

示例10: upgradeSettingsGeneric

import java.util.TreeMap; //导入方法依赖的package包/类
private static Set<String> upgradeSettingsGeneric(Map<String, TreeMap<Integer, SettingsDescription>> settings,
        Map<String, Object> validatedSettingsMutable, Set<String> deletedSettingsMutable, int toVersion) {
    for (Entry<String, TreeMap<Integer, SettingsDescription>> versions : settings.entrySet()) {
        String settingName = versions.getKey();
        TreeMap<Integer, SettingsDescription> versionedSettings = versions.getValue();

        boolean isNewlyAddedSetting = versionedSettings.firstKey() == toVersion;
        if (isNewlyAddedSetting) {
            boolean wasHandledByCustomUpgrader = validatedSettingsMutable.containsKey(settingName);
            if (wasHandledByCustomUpgrader) {
                continue;
            }

            SettingsDescription setting = versionedSettings.get(toVersion);
            if (setting == null) {
                throw new AssertionError("First version of a setting must be non-null!");
            }
            upgradeSettingInsertDefault(validatedSettingsMutable, settingName, setting);
        }

        Integer highestVersion = versionedSettings.lastKey();
        boolean isRemovedSetting = (highestVersion == toVersion && versionedSettings.get(highestVersion) == null);
        if (isRemovedSetting) {
            if (deletedSettingsMutable == null) {
                deletedSettingsMutable = new HashSet<>();
            }
            upgradeSettingRemove(validatedSettingsMutable, deletedSettingsMutable, settingName);
        }
    }
    return deletedSettingsMutable;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:32,代码来源:Settings.java

示例11: writeIdentity

import java.util.TreeMap; //导入方法依赖的package包/类
private static void writeIdentity(XmlSerializer serializer, String accountUuid, String identity,
        Map<String, Object> prefs) throws IOException {

    serializer.startTag(null, IDENTITY_ELEMENT);

    String prefix = accountUuid + ".";
    String suffix = "." + identity;

    // Write name belonging to the identity
    String name = (String) prefs.get(prefix + Account.IDENTITY_NAME_KEY + suffix);
    serializer.startTag(null, NAME_ELEMENT);
    serializer.text(name);
    serializer.endTag(null, NAME_ELEMENT);

    // Write email address belonging to the identity
    String email = (String) prefs.get(prefix + Account.IDENTITY_EMAIL_KEY + suffix);
    serializer.startTag(null, EMAIL_ELEMENT);
    serializer.text(email);
    serializer.endTag(null, EMAIL_ELEMENT);

    // Write identity description
    String description = (String) prefs.get(prefix + Account.IDENTITY_DESCRIPTION_KEY + suffix);
    if (description != null) {
        serializer.startTag(null, DESCRIPTION_ELEMENT);
        serializer.text(description);
        serializer.endTag(null, DESCRIPTION_ELEMENT);
    }

    // Write identity settings
    serializer.startTag(null, SETTINGS_ELEMENT);
    for (Map.Entry<String, Object> entry : prefs.entrySet()) {
        String key = entry.getKey();
        String valueString = entry.getValue().toString();
        String[] comps = key.split("\\.");

        if (comps.length < 3) {
            // Skip non-identity config entries
            continue;
        }

        String keyUuid = comps[0];
        String identityKey = comps[1];
        String identityIndex = comps[2];
        if (!keyUuid.equals(accountUuid) || !identityIndex.equals(identity)) {
            // Skip entries that belong to another identity
            continue;
        }

        TreeMap<Integer, SettingsDescription> versionedSetting = IdentitySettings.SETTINGS.get(identityKey);

        if (versionedSetting != null) {
            Integer highestVersion = versionedSetting.lastKey();
            SettingsDescription setting = versionedSetting.get(highestVersion);

            if (setting != null) {
                // Only write settings that have an entry in IdentitySettings.SETTINGS
                try {
                    writeKeyAndPrettyValueFromSetting(serializer, identityKey, setting, valueString);
                } catch (InvalidSettingValueException e) {
                    Timber.w("Identity setting \"%s\" has invalid value \"%s\" in preference storage. " +
                            "This shouldn't happen!", identityKey, valueString);
                }
            }
        }
    }
    serializer.endTag(null, SETTINGS_ELEMENT);

    serializer.endTag(null, IDENTITY_ELEMENT);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:70,代码来源:SettingsExporter.java

示例12: writeFolder

import java.util.TreeMap; //导入方法依赖的package包/类
private static void writeFolder(XmlSerializer serializer, String accountUuid, String folder,
        Map<String, Object> prefs) throws IOException {

    serializer.startTag(null, FOLDER_ELEMENT);
    serializer.attribute(null, NAME_ATTRIBUTE, folder);

    // Write folder settings
    for (Map.Entry<String, Object> entry : prefs.entrySet()) {
        String key = entry.getKey();
        String valueString = entry.getValue().toString();
        int indexOfFirstDot = key.indexOf('.');
        int indexOfLastDot = key.lastIndexOf('.');

        if (indexOfFirstDot == -1 || indexOfLastDot == -1 || indexOfFirstDot == indexOfLastDot) {
            // Skip non-folder config entries
            continue;
        }

        String keyUuid = key.substring(0, indexOfFirstDot);
        String folderName = key.substring(indexOfFirstDot + 1, indexOfLastDot);
        String folderKey = key.substring(indexOfLastDot + 1);

        if (!keyUuid.equals(accountUuid) || !folderName.equals(folder)) {
            // Skip entries that belong to another folder
            continue;
        }

        TreeMap<Integer, SettingsDescription> versionedSetting = FolderSettings.SETTINGS.get(folderKey);

        if (versionedSetting != null) {
            Integer highestVersion = versionedSetting.lastKey();
            SettingsDescription setting = versionedSetting.get(highestVersion);

            if (setting != null) {
                // Only write settings that have an entry in FolderSettings.SETTINGS
                try {
                    writeKeyAndPrettyValueFromSetting(serializer, folderKey, setting, valueString);
                } catch (InvalidSettingValueException e) {
                    Timber.w("Folder setting \"%s\" has invalid value \"%s\" in preference storage. " +
                            "This shouldn't happen!", folderKey, valueString);
                }
            }
        }
    }

    serializer.endTag(null, FOLDER_ELEMENT);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:48,代码来源:SettingsExporter.java

示例13: getInstantValue

import java.util.TreeMap; //导入方法依赖的package包/类
public final double getInstantValue(String key, long time, String newVal) {

        TreeMap<Long, String> h = null;
        if (!lastValues.containsKey(key)) {
            h = new TreeMap<Long, String>();
            lastValues.put(key, h);
        } else
            h = lastValues.get(key);
        if (h.size() == 0) {
            h.put(time, newVal);
            return 0D;
        }
        if (h.size() == 2)
            h.remove(h.firstKey());
        h.put(time, newVal);
        long first = h.firstKey();
        long last = h.lastKey();
        String s1 = h.get(first);
        String s2 = h.get(last);
        double d = 0D;
        try {
            d = Double.parseDouble(diffWithOverflowCheck(s2, s1));
        } catch (Throwable t) {
            d = 0D;
        }
        d = d / ((last - first) / 1000D);
        return d;


//		TreeMap<Long, String> h = null;
//		if (!lastValues.containsKey(key)) {
//			h = new TreeMap<Long, String>();
//			lastValues.put(key, h);
//		} else
//			h = lastValues.get(key);
//		h.put(time, newVal);
//		if (h.size() == 1) return 0D;
//		long first = h.firstKey();
//		long last = h.lastKey();
//		String s1 = h.get(first);
//		String s2 = h.get(last);
//		double d = 0D;
//		try {
//			d = Double.parseDouble(diffWithOverflowCheck(s2, s1));
//		} catch (Throwable t) {
//			d = 0D;
//		}
//		d = d / ((last - first) / 1000D);
//		long diffTime = 60 * 1000;
//		if (properties != null)
//			diffTime = properties.geti("stat.interval", 60, "The interval to consider when computing the instant values") * 1000;
//		if (diffTime <= 0) diffTime = 60 * 1000;
//		if ((last - first) < diffTime) {
//			h.clear();
//			h.put(first, s1);
//			h.put(last, s2);
//		} else {
//			long inner = last - diffTime;
//			String ss = diffWithOverflowCheck(s2, s1);
//			double dd = 0D;
//			try { dd = Double.parseDouble(ss); } catch (Throwable t) { dd = 0D; }
//			dd = dd * (inner - first) / (last - first);
//			h.clear();
//			h.put(inner, addWithOverflowCheck(s1, ""+dd));
//			h.put(last, s2);
//		}
//		return d;
    }
 
开发者ID:fast-data-transfer,项目名称:fdt,代码行数:69,代码来源:StatisticsHandler.java

示例14: refreshGroupSelections

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Refresh group selections.
 * 
 * @param tableViewer
 *            the table viewer
 * @param indexOfRow
 *            the index of row
 * @param addOrDeleteRow
 *            the add or delete row
 * @param groupSelectionMap
 *            the group selection map
 * @return true, if successful
 */
public boolean refreshGroupSelections(TableViewer tableViewer, int indexOfRow,String addOrDeleteRow,
	TreeMap<Integer,List<List<Integer>>> groupSelectionMap){
	boolean isRemoveColumn = false;
	for(int key:groupSelectionMap.keySet()){
		List<List<Integer>> groups = groupSelectionMap.get(key);
		boolean isNewIndexAddedorRemoved=false;
		for (List<Integer> grp : groups) {
			List<Integer> tempGrp= new ArrayList<>(grp);
			if("ADD".equalsIgnoreCase(addOrDeleteRow)){
				for (int i = 0; i < grp.size(); i++) {
					if(grp.get(i)>=indexOfRow){
						grp.set(i, grp.get(i) + 1);
					}
				}
				if(tempGrp.contains(indexOfRow)){
					if(!isNewIndexAddedorRemoved && tempGrp.get(0)!=indexOfRow){//other than starting index then add row.
						grp.add(tempGrp.indexOf(indexOfRow),indexOfRow);
						isNewIndexAddedorRemoved=true;
					}
				}
			}else if("DEL".equalsIgnoreCase(addOrDeleteRow)){
				if(tempGrp.contains(indexOfRow)){
					if(!isNewIndexAddedorRemoved){//other than starting index then add row.
						grp.remove(grp.indexOf(indexOfRow));
						if(grp.size()==1){
							grp.clear();
						}
						if(rearrangeGroupsAfterDeleteRow(groupSelectionMap, grp)&& groupSelectionMap.lastKey()!=key){
							grp.clear();
						}
						List tempList=new ArrayList<>(); 
						for (List lst : groupSelectionMap.get(key)) {
							tempList.addAll(lst);
						}
						if(tempList.isEmpty()){
							isRemoveColumn=true;
						}
					}
					isNewIndexAddedorRemoved=true;
				}
				for (int i = 0; i < grp.size(); i++) {
					if(grp.get(i)>=indexOfRow){
						grp.set(i, grp.get(i) -1);
					}
				}
			}
			tempGrp.clear();	
		}
	}
	return isRemoveColumn;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:65,代码来源:FilterHelper.java


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