本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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);
}
示例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;
}
}
示例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};
}
示例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();
}
示例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);
}
}
示例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());
}
}
示例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;
}
示例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;
}
}
示例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;
}