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


Java TreeMap.size方法代码示例

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


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

示例1: hasEqualDomainSettings

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Checks for equal domain settings.
 *
 * @param ggsToCompare the GeneralGraphSettings4MAS to compare
 * @return true, if successful
 */
public boolean hasEqualDomainSettings(GeneralGraphSettings4MAS ggsToCompare) {
	
	boolean isEqual = true;
	TreeMap<String, DomainSettings> dsTreeMapToCompare = ggsToCompare.getDomainSettings();
	isEqual = (dsTreeMapToCompare.size()==this.getDomainSettings().size());
	if (isEqual==true) {
		// --- Compare each element in the TreeMap ----
		Vector<String> keyVector = new Vector<String>(dsTreeMapToCompare.keySet());
		for (int i = 0; i < keyVector.size(); i++) {
			String key = keyVector.get(i);
			DomainSettings ds2Comp = dsTreeMapToCompare.get(key);
			DomainSettings dsLocal = this.getDomainSettings().get(key);
			if (dsLocal==null) return false;
			if (isEqualDomainSetting(ds2Comp, dsLocal)==false) return false;
		}
	}
	return isEqual;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:GeneralGraphSettings4MAS.java

示例2: setTemplates

import java.util.TreeMap; //导入方法依赖的package包/类
public void setTemplates(TreeMap<String, int[][]> templates)
{
	// TODO: Find a better way to do this.
	
	getSettings().clear();
	addSetting(mode);
	addSetting(useAi);
	
	this.templates =
		templates.values().toArray(new int[templates.size()][][]);
	
	int selected;
	if(template != null && template.getSelected() < templates.size())
		selected = template.getSelected();
	else
		selected = 0;
	
	template = new ModeSetting("Template",
		templates.keySet().toArray(new String[templates.size()]), selected);
	
	addSetting(template);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:23,代码来源:AutoBuildMod.java

示例3: 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

示例4: buildResource

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * 将path、queryParam、formParam合成一个字符串
 *
 */
private static String buildResource(String pathWithParams, Map<String, String> queryParams, Map<String, String> formParams) {
    StringBuilder result = new StringBuilder();
    result.append(pathWithParams);

    //使用TreeMap,默认按照字母排序
    TreeMap<String, String> parameter = new TreeMap<String, String>();
    if (MapUtils.isNotEmpty(queryParams)) {
        parameter.putAll(queryParams);
    }
    if (MapUtils.isNotEmpty(formParams)) {
        parameter.putAll(formParams);
    }

    if (parameter.size() > 0) {
        result.append("?");

        // bugfix by [email protected]: "kv separator should be ignored while value is empty, ex. k1=v1&k2&k3=v3&k4"
        List<String> comboMap = new ArrayList<String>();
        for(Entry<String, String> entry : parameter.entrySet()){
            String comboResult = entry.getKey() + (StringUtils.isNotEmpty(entry.getValue())? "="+entry.getValue() : StringUtils.EMPTY);
            comboMap.add(comboResult);
        }
        Joiner joiner = Joiner.on("&");
        result.append(joiner.join(comboMap));
    }
    return result.toString();
}
 
开发者ID:aliyun,项目名称:apigateway-sdk-core,代码行数:32,代码来源:SignUtil.java

示例5: build

import java.util.TreeMap; //导入方法依赖的package包/类
public int build(TreeMap<String, Integer> keyValueMap)
{
    idToLabelMap = new String[keyValueMap.size()];
    for (Map.Entry<String, Integer> entry : keyValueMap.entrySet())
    {
        idToLabelMap[entry.getValue()] = entry.getKey();
    }
    return trie.build(keyValueMap);
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:10,代码来源:Alphabet.java

示例6: editSeriesAddOrExchangeData

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Edits the data series by adding or exchanging data.
 * @param series the series
 * @param targetDataSeriesIndex the target data series index
 */
public void editSeriesAddOrExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {

	if (targetDataSeriesIndex<=(this.getColumnCount()-1)) {
		
		boolean dataWereAdded = false;
		int targetTbIndex = targetDataSeriesIndex+1;
		TreeMap<Number, Vector<Number>> tableDataTreeMap = new TreeMap<Number, Vector<Number>>(this.tableModelDataVector.getKeyRowVectorTreeMap()); 
		
		List valuePairs = parentDataModel.getValuePairsFromSeries(series);
		for (int i = 0; i < valuePairs.size(); i++) {
			// --- Find the key in the table ----------
			ValuePair vp = (ValuePair) valuePairs.get(i);
			Number key = parentDataModel.getXValueFromPair(vp);
			Number value = parentDataModel.getYValueFromValuePair(vp);

			Vector<Number> editRow = tableDataTreeMap.get(key);
			if (editRow==null) {
				// --- Add a new row ------------------
				editRow = new Vector<Number>();
				while(editRow.size() < this.getColumnCount()){
					editRow.add(null);
				}
				editRow.set(0, key);
				editRow.set(targetTbIndex, value);
				tableDataTreeMap.put(key, editRow);
				dataWereAdded = true;
				
			} else {
				// --- Finally edit the row -----------
				editRow.set(targetTbIndex, value);
			}
		}
		
		// --- Finally update the table, if necessary -
		if (dataWereAdded==true) {
			// --- Rebuild the table ------------------
			Number[] keyArray = new Number[tableDataTreeMap.size()]; 
			tableDataTreeMap.keySet().toArray(keyArray);
			for (int i=0; i<keyArray.length; i++) {
				Number keyTreeMap = keyArray[i];
				if ((valuePairs.size()-1)<i) {
					// --- Just add new data ----------
					this.tableModelDataVector.add(i, tableDataTreeMap.get(keyTreeMap));
				} else {
					Number keyValuePair = parentDataModel.getXValueFromPair((ValuePair) valuePairs.get(i));
					if (keyTreeMap.equals(keyValuePair)==false) {
						// --- New data was found -----
						this.tableModelDataVector.add(i, tableDataTreeMap.get(keyTreeMap));
					}	
				}
			}	
		}
		this.fireTableStructureChanged();
		
	} else {
		throw new NoSuchSeriesException();
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:64,代码来源:TimeSeriesTableModel.java

示例7: getDerivate

import java.util.TreeMap; //导入方法依赖的package包/类
public Monomial getDerivate(NumericVariable var){
if (!containsVariable(var))
    return null;
TreeMap<NumericVariable, Integer> vars = new TreeMap<NumericVariable, Integer>();
for (NumericVariable variable: variables.keySet()){
    int exp = variables.get(variable);
    if (variable.equals(var))
	exp--;
    if (exp > 0)
	vars.put(variable, exp);
}
if (vars.size() == 0)
    return null;
return new Monomial(vars);
   }
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:16,代码来源:Monomial.java

示例8: getAvailableFontFamilyNames

import java.util.TreeMap; //导入方法依赖的package包/类
public String[] getAvailableFontFamilyNames(Locale requestedLocale) {
    FontManagerForSGE fm = getFontManagerForSGE();
    String[] installed = fm.getInstalledFontFamilyNames(requestedLocale);
    /* Use a new TreeMap as used in getInstalledFontFamilyNames
     * and insert all the keys in lower case, so that the sort order
     * is the same as the installed families. This preserves historical
     * behaviour and inserts new families in the right place.
     * It would have been marginally more efficient to directly obtain
     * the tree map and just insert new entries, but not so much as
     * to justify the extra internal interface.
     */
    TreeMap<String, String> map = fm.getCreatedFontFamilyNames();
    if (map == null || map.size() == 0) {
        return installed;
    } else {
        for (int i=0; i<installed.length; i++) {
            map.put(installed[i].toLowerCase(requestedLocale),
                    installed[i]);
        }
        String[] retval =  new String[map.size()];
        Object [] keyNames = map.keySet().toArray();
        for (int i=0; i < keyNames.length; i++) {
            retval[i] = map.get(keyNames[i]);
        }
        return retval;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:SunGraphicsEnvironment.java

示例9: getPartValueAtTime

import java.util.TreeMap; //导入方法依赖的package包/类
public static float[] getPartValueAtTime(TreeMap<Integer, AnimationPart> animations, float time)
{
	if(animations != null && animations.size() > 0)
	{
		AnimationPart anim = findPartForTime(animations, MathHelper.floor(time));
		if (anim == null)
			anim = animations.lastEntry().getValue();
		float frameTime = Math.min(time - anim.getStartTime(), anim.getEndTime() - anim.getStartTime());
		return anim.getPartRotationAtTime(null, frameTime);
	}
	else
		return new float[]{0,0,0};
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:14,代码来源:AnimationSequence.java

示例10: importPrimaryKeyOfTable

import java.util.TreeMap; //导入方法依赖的package包/类
public void importPrimaryKeyOfTable(DBTable table, PKReceiver receiver) {
    LOGGER.debug("Importing primary keys for table '{}'", table);
    StopWatch watch = new StopWatch("importPrimaryKeyOfTable");
    ResultSet pkset = null;
    try {
     pkset = metaData.getPrimaryKeys(catalogName, schemaName, table.getName());
     TreeMap<Short, String> pkComponents = new TreeMap<Short, String>();
     String pkName = null;
     while (pkset.next()) {
     	String tableName = pkset.getString(3);
         if (!tableName.equals(table.getName())) // Bug fix for Firebird: 
         	continue;							// When querying X, it returns the pks of XY too
	
         String columnName = pkset.getString(4);
         short keySeq = pkset.getShort(5);
         pkComponents.put(keySeq, columnName);
         pkName = pkset.getString(6);
            LOGGER.debug("found pk column {}, {}, {}", new Object[] { columnName, keySeq, pkName });
     }
     if (pkComponents.size() > 0) {
      String[] columnNames = pkComponents.values().toArray(new String[pkComponents.size()]);
      receiver.receivePK(pkName, dialect.isDeterministicPKName(pkName), columnNames, table);
     }
    } catch (SQLException e) {
    	errorHandler.handleError("Error importing primary key of table " + table.getName());
    } finally {
    	DBUtil.close(pkset);
    }
    watch.stop();
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:31,代码来源:JDBCDBImporter.java

示例11: crawl

import java.util.TreeMap; //导入方法依赖的package包/类
public void crawl() {
    String file = "E:\\work\\githubcode\\financehelper\\financehelper-samples\\src\\main\\resources\\新建文本文档.txt";
    String charsetName = "GB2312";
    TreeMap<Integer, String> results = FileUtil.readFileByLines(file, charsetName);
    for (int i = 1; i <= results.size(); i = i + 3) {
        String date = results.get(i);
        date = date.replace("【 ", "").replace(" 】", "");
        date = DateUtil.dateToString(new Date(date), DateUtil.DATE_FORMAT_DAY_SHORT);

        /*String temp2 = results.get(i + 1);
        String[] arrTemp2 = temp2.split(",");
        for (String str : arrTemp2) {
            IndustryInfo industryInfo = new IndustryInfo();
            industryInfo.setDate(Integer.parseInt(date));
            industryInfo.setIndustryName(str.substring(str.lastIndexOf("【") + 1, str.lastIndexOf("】")));
            industryInfo.setRise(new BigDecimal(str.substring(str.lastIndexOf("】") + 1, str.length())));
            industryInfoDao.add(industryInfo);
        }
        String temp3 = results.get(i + 2);
        String[] arrTemp3 = temp3.split(",");
        for (String str : arrTemp3) {
            IndustryInfo industryInfo = new IndustryInfo();
            industryInfo.setDate(Integer.parseInt(date));
            industryInfo.setIndustryName(str.substring(str.lastIndexOf("【") + 1, str.lastIndexOf("】")));
            Double d = Double.parseDouble(str.substring(str.lastIndexOf("】") + 1, str.length())) * 10000;
            industryInfo.setTotal(d.intValue());
            industryInfoDao.add(industryInfo);
        }*/
        System.out.println(date);
    }
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:32,代码来源:IndustryInfoLocalProcessor.java

示例12: setupOtherGroupReportDTO

import java.util.TreeMap; //导入方法依赖的package包/类
/**
    * Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key is the
    * group/session name. The code ensures that the session name is unique, adding the session id if necessary. It will
    * only include the finalized reports.
    */
   private void setupOtherGroupReportDTO(HttpServletRequest request, ScribeSession scribeSession,
    ScribeUser scribeUser) {
TreeMap<String, ScribeSessionDTO> otherScribeSessions = ScribeUtils.getReportDTOs(scribeSession);
if (otherScribeSessions.size() > 0) {
    request.setAttribute("otherScribeSessions", otherScribeSessions.values());
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:LearningAction.java

示例13: toArray

import java.util.TreeMap; //导入方法依赖的package包/类
/**
    * Converts the map (indexed by java.lang.Integers) into an array.
    */
   protected static Integer[] toArray(TreeMap map) {
int size = map.size() == 0 ? 0 : 1 + ((Integer) map.lastKey()).intValue();
Integer[] ary = new Integer[size];
Iterator it = map.keySet().iterator();

while (it.hasNext()) {
    Integer idx = (Integer) it.next();
    Integer val = (Integer) map.get(idx);
    ary[idx.intValue()] = val;
}
return ary;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Diff.java

示例14: getAvailableFontFamilyNames

import java.util.TreeMap; //导入方法依赖的package包/类
public String[] getAvailableFontFamilyNames(Locale requestedLocale) {
    FontManagerForSGE fm = getFontManagerForSGE();
    String[] installed = fm.getInstalledFontFamilyNames(requestedLocale);
    /* Use a new TreeMap as used in getInstalledFontFamilyNames
     * and insert all the keys in lower case, so that the sort order
     * is the same as the installed families. This preserves historical
     * behaviour and inserts new families in the right place.
     * It would have been marginally more efficient to directly obtain
     * the tree map and just insert new entries, but not so much as
     * to justify the extra internal interface.
     */
    TreeMap<String, String> map = fm.getCreatedFontFamilyNames();
    if (map == null || map.size() == 0) {
        return installed;
    } else {
        for (int i=0; i<installed.length; i++) {
            map.put(installed[i].toLowerCase(requestedLocale),
                    installed[i]);
        }
        String[] retval =  new String[map.size()];
        Object [] keyNames = map.keySet().toArray();
        for (int i=0; i < keyNames.length; i++) {
            retval[i] = (String)map.get(keyNames[i]);
        }
        return retval;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:SunGraphicsEnvironment.java

示例15: 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


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