本文整理汇总了Java中java.util.SortedMap.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java SortedMap.entrySet方法的具体用法?Java SortedMap.entrySet怎么用?Java SortedMap.entrySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.SortedMap
的用法示例。
在下文中一共展示了SortedMap.entrySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterAssignments
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* Filters assignments per HIT, i.e. first n assignments by time
*
* @param assignments existing assignments
* @param <T> type of assignments (integer, boolean, etc.)
* @return new sorted map with filtered assignments
*/
public <T> SortedMap<String, SortedSet<SingleWorkerAssignment<T>>> filterAssignments(
SortedMap<String, SortedSet<SingleWorkerAssignment<T>>> assignments)
{
SortedMap<String, SortedSet<SingleWorkerAssignment<T>>> result = new TreeMap<>();
for (Map.Entry<String, SortedSet<SingleWorkerAssignment<T>>> entry : assignments
.entrySet()) {
SortedSet<SingleWorkerAssignment<T>> filtered = filter(entry.getValue());
if (!filtered.isEmpty()) {
result.put(entry.getKey(), filtered);
}
}
return result;
}
示例2: printFrameSizeHistogram
import java.util.SortedMap; //导入方法依赖的package包/类
private static void printFrameSizeHistogram(List<Integer> frameSizes) {
final int step = 1000;
SortedMap<Integer,Integer> frameSizeCounts = new TreeMap<>();
int maxKeyLen = 0;
for (int fs : frameSizes) {
int key = (int)Math.round((double)fs / step);
maxKeyLen = Math.max(Integer.toString(key * step).length(), maxKeyLen);
if (!frameSizeCounts.containsKey(key))
frameSizeCounts.put(key, 0);
frameSizeCounts.put(key, frameSizeCounts.get(key) + 1);
}
for (int i = frameSizeCounts.firstKey(); i < frameSizeCounts.lastKey(); i++) {
if (!frameSizeCounts.containsKey(i))
frameSizeCounts.put(i, 0);
}
List<String> frameSizeLabels = new ArrayList<>();
List<Double> frameSizeValues = new ArrayList<>();
for (Map.Entry<Integer,Integer> entry : frameSizeCounts.entrySet()) {
frameSizeLabels.add(String.format("%" + maxKeyLen + "d", entry.getKey() * step));
frameSizeValues.add((double)entry.getValue());
}
printNormalizedBarGraph("Frame sizes (bytes)", frameSizeLabels, frameSizeValues);
}
示例3: parseTypes
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* parses a list of MappingCharFilter style rules into a custom byte[] type table
*/
static byte[] parseTypes(Collection<String> rules) {
SortedMap<Character, Byte> typeMap = new TreeMap<>();
for (String rule : rules) {
Matcher m = typePattern.matcher(rule);
if (!m.find())
throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]");
String lhs = parseString(m.group(1).trim());
Byte rhs = parseType(m.group(2).trim());
if (lhs.length() != 1)
throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]. Only a single character is allowed.");
if (rhs == null)
throw new RuntimeException("Invalid Mapping Rule : [" + rule + "]. Illegal type.");
typeMap.put(lhs.charAt(0), rhs);
}
// ensure the table is always at least as big as DEFAULT_WORD_DELIM_TABLE for performance
byte types[] = new byte[Math.max(typeMap.lastKey() + 1, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE.length)];
for (int i = 0; i < types.length; i++)
types[i] = WordDelimiterIterator.getType(i);
for (Map.Entry<Character, Byte> mapping : typeMap.entrySet())
types[mapping.getKey()] = mapping.getValue();
return types;
}
示例4: createSign
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* 创建签名
* @param parameters
* @return
*/
public static String createSign(SortedMap<Object, Object> parameters) {
StringBuffer sb = new StringBuffer();
Set<Entry<Object, Object>> es = parameters.entrySet();// 所有参与传参的参数按照accsii排序(升序)
Iterator<Entry<Object, Object>> it = es.iterator();
while (it.hasNext()) {
Entry<Object, Object> entry = (Entry<Object, Object>) it
.next();
String k = (String) entry.getKey();
Object v = entry.getValue();
if (null != v && !"".equals(v) && !"sign".equals(k)
&& !"key".equals(k)) {
sb.append(k + "=" + v + "&");
}
}
sb.append("key=" + Constant.SIGNATURE_KEY);
String sign = DigestUtil.MD5(sb.toString()).toUpperCase();
return sign;
}
示例5: diff
import java.util.SortedMap; //导入方法依赖的package包/类
private static void diff(String locale1, String locale2) throws IOException {
Properties en = new Properties();
en.load(MissingTranslations.class.getResourceAsStream("/org/airsonic/player/i18n/ResourceBundle_" + locale1 + ".properties"));
SortedMap<Object,Object> enSorted = new TreeMap<Object, Object>(en);
Properties mk = new Properties();
mk.load(MissingTranslations.class.getResourceAsStream("/org/airsonic/player/i18n/ResourceBundle_" + locale2 + ".properties"));
System.out.println("\nMessages present in locale " + locale1 + " and missing in locale " + locale2 + ":");
int count = 0;
for (Map.Entry<Object, Object> entry : enSorted.entrySet()) {
if (!mk.containsKey(entry.getKey())) {
System.out.println(entry.getKey() + " = " + entry.getValue());
count++;
}
}
System.out.println("\nTotal: " + count);
}
示例6: buildGammaMap
import java.util.SortedMap; //导入方法依赖的package包/类
private static ImmutableSortedMap<Integer, BigDecimal> buildGammaMap(Map<Integer, BigDecimal> gammaInput) {
ImmutableSortedMap.Builder<Integer, BigDecimal> mapBuilder = ImmutableSortedMap.naturalOrder();
SortedMap<Integer, BigDecimal> sortedInput = new TreeMap<>(gammaInput);
Preconditions.checkArgument(sortedInput.firstKey() == 1,
"Gamma Values must (exclusively) be specified for quantities 1 and (optionally) higher",
sortedInput);
Preconditions.checkArgument(sortedInput.lastKey().equals(sortedInput.size()), ""
+ "Gamma Values must be specified for all capacities in {0, ..., k_{max}}, where k_{max} > 0 is any natural number > 0",
sortedInput);
for (Entry<Integer, BigDecimal> inputGammaEntry : sortedInput.entrySet()) {
Preconditions.checkArgument(inputGammaEntry.getValue().compareTo(BigDecimal.ZERO) >= 0, "Gamma must not be negative", inputGammaEntry);
mapBuilder.put(inputGammaEntry);
}
return mapBuilder.build();
}
示例7: createSwitch
import java.util.SortedMap; //导入方法依赖的package包/类
private static IntegerSwitchNode createSwitch(ValuePhiNode switchedValue, SortedMap<Integer, AbstractBeginNode> dispatchTable, AbstractBeginNode defaultSuccessor) {
int numKeys = dispatchTable.size();
int numSuccessors = numKeys + 1;
AbstractBeginNode[] switchSuccessors = new AbstractBeginNode[numSuccessors];
int[] switchKeys = new int[numKeys];
double[] switchKeyProbabilities = new double[numSuccessors];
int[] switchKeySuccessors = new int[numSuccessors];
int idx = 0;
for (Map.Entry<Integer, AbstractBeginNode> entry : dispatchTable.entrySet()) {
switchSuccessors[idx] = entry.getValue();
switchKeys[idx] = entry.getKey();
switchKeyProbabilities[idx] = 1d / numKeys;
switchKeySuccessors[idx] = idx;
idx++;
}
switchSuccessors[idx] = defaultSuccessor;
/* We know the default branch is never going to be executed. */
switchKeyProbabilities[idx] = 0;
switchKeySuccessors[idx] = idx;
return new IntegerSwitchNode(switchedValue, switchSuccessors, switchKeys, switchKeyProbabilities, switchKeySuccessors);
}
示例8: keepDebate
import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public boolean keepDebate(Debate debate)
throws IOException
{
// collect counts for each stance
SortedMap<String, Integer> counts = new TreeMap<>();
for (Argument argument : debate.getArgumentList()) {
String stance = argument.getStance();
if (argument.getParentId() == null) {
if (!counts.containsKey(stance)) {
counts.put(stance, 0);
}
counts.put(stance, counts.get(stance) + 1);
}
}
// make sure we have two stances
if (counts.size() < 2) {
return false;
}
// check constraints for each stance
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() <= MINIMUM_NUMBER_OF_FIRST_LEVEL_ARGUMENTS_PER_SIDE) {
return false;
}
}
return true;
}
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:33,代码来源:MinimumRootArgumentCountFilterCreateDebate.java
示例9: aggressiveRemoveObsoleteStatements
import java.util.SortedMap; //导入方法依赖的package包/类
private int aggressiveRemoveObsoleteStatements(MemoryPoolMXBean tenuredPool, SortedMap<Long, StatementPosInPool> mapStatements, int nNbStatementForcedRemoved, int nNbSystemGCCall)
{
boolean bGCToDo = false;
int nNbStatementRemoved = 0;
Set<Map.Entry<Long, StatementPosInPool>> set = mapStatements.entrySet();
Iterator<Map.Entry<Long, StatementPosInPool>> iterMapEntry = set.iterator();
boolean bMemUsageTooMuch = true;
while(iterMapEntry.hasNext() && bMemUsageTooMuch)
{
Map.Entry<Long, StatementPosInPool> mapEntry = iterMapEntry.next();
StatementPosInPool statementPosInPool = mapEntry.getValue();
boolean bRemoved = statementPosInPool.forceRemoveStatement();
if(bRemoved)
{
bGCToDo = true;
nNbStatementRemoved++;
if((nNbStatementRemoved % nNbStatementForcedRemoved) == 0)
{
tryForceGC(nNbSystemGCCall);
bGCToDo = false;
bMemUsageTooMuch = tenuredPool.isUsageThresholdExceeded();
}
}
}
if(bGCToDo)
{
tryForceGC(nNbSystemGCCall);
}
return nNbStatementRemoved;
}
示例10: getPublicPackagesForPlugin
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* Transforms public packages in form of "selected items" map into
* set of strings describing public packages in maven-nbm-plugin syntax.
*/
public static SortedSet<String> getPublicPackagesForPlugin (SortedMap<String, Boolean> selItems) {
SortedSet<String> result = new TreeSet<String>();
Set<String> processed = new HashSet<String>();
for (Entry<String, Boolean> entry : selItems.entrySet()) {
if (entry.getValue() && !processed.contains(entry.getKey())) {
boolean allSubpackages = true;
Set<String> processedCandidates = new HashSet<String>();
String prefix = entry.getKey() + ".";
for (String key : selItems.keySet()) {
if (key.startsWith(prefix)) {
if (selItems.get(key)) {
processedCandidates.add(key);
} else {
allSubpackages = false;
break;
}
}
}
if (allSubpackages && processedCandidates.size() > COALESCE_LIMIT) {
result.add(entry.getKey() + ALL_SUBPACKAGES);
processed.addAll(processedCandidates);
} else {
result.add(entry.getKey());
}
}
}
return result;
}
示例11: toStringBuffer
import java.util.SortedMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static StringBuffer toStringBuffer(Map<String, Object> unsortedMap, int indent)
{
StringBuffer tabs = new StringBuffer();
for (int i = 0; i < indent; i++)
{
tabs.append("\t");
}
StringBuffer sb = new StringBuffer();
SortedMap<String, Object> map = new TreeMap<String, Object>();
map.putAll(unsortedMap);
for (Map.Entry<String, Object> entry : map.entrySet())
{
if (entry.getValue() instanceof Map)
{
sb.append(tabs).append(entry.getKey()).append(":").append(entry.getValue().getClass()).append("\n");
sb.append(JSONtoFmModel.toStringBuffer((Map<String, Object>)entry.getValue(), indent+1));
}
else if (entry.getValue() instanceof List)
{
sb.append(tabs).append("[\n");
List l = (List)entry.getValue();
for (int i = 0; i < l.size(); i++)
{
sb.append(tabs).append(l.get(i)).append(":").append((l.get(i) != null) ? l.get(i).getClass() : "null").append("\n");
}
sb.append(tabs).append("]\n");
}
else
{
sb.append(tabs).append(entry.getKey()).append(":").append(entry.getValue()).append(":").append((entry.getValue() != null ? entry.getValue().getClass() : "null")).append("\n");
}
}
return sb;
}
示例12: processKeyMap
import java.util.SortedMap; //导入方法依赖的package包/类
/**
* process not null parameters for parameters map
* @param map
* @param process
*/
private void processKeyMap(@NonNull SortedMap<String, String> map,
@NonNull ProcessNotNullMapParameters process){
if (!map.isEmpty()) {
for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getValue() != null && !entry.getValue().isEmpty())
process.process(entry.getKey().toString(), entry.getValue());
}
}
}
示例13: writeAttributes
import java.util.SortedMap; //导入方法依赖的package包/类
static void writeAttributes(
OutputStream out, SortedMap<String, String> attributesSortedByName) throws IOException {
for (Map.Entry<String, String> attribute : attributesSortedByName.entrySet()) {
String attrName = attribute.getKey();
String attrValue = attribute.getValue();
writeAttribute(out, attrName, attrValue);
}
}
示例14: applySingleMapping
import java.util.SortedMap; //导入方法依赖的package包/类
private <T> SortedMap<T, String> applySingleMapping(SortedMap<T, String> original, Map<String, String> mappingValues) {
SortedMap<T, String> mappedValues = new TreeMap<T, String>();
for (Map.Entry<T, String> entry : original.entrySet()) {
String key = entry.getValue();
if(mappingValues.containsKey(key)) {
//entry.setValue(mappingValues.get(entry.getValue()));
mappedValues.put(entry.getKey(), mappingValues.get(key));
} else {
// pass empty string if no mapping value is found in the custom parameter, could also use get with default here
mappedValues.put(entry.getKey(), "");
}
}
return mappedValues;
}
示例15: testOneInPackage
import java.util.SortedMap; //导入方法依赖的package包/类
/** If package contains only one resource it is not too frendly to our classloaders.
* Generally not a big problem OTOH we want to avoid this if this is simple.
*/
public void testOneInPackage() throws Exception {
SortedSet<Violation> violations = new TreeSet<Violation>();
for (File f: org.netbeans.core.startup.Main.getModuleSystem().getModuleJars()) {
// check JAR files only
if (!f.getName().endsWith(".jar"))
continue;
// ignore branding
if (f.getName().endsWith("_nb.jar"))
continue;
// a lot of alarms for 3rd party JARs
if (f.getName().contains("modules/ext/"))
continue;
SortedMap<String, Integer> resourcesPerPackage = new TreeMap<String, Integer>();
JarFile jar = new JarFile(f);
Enumeration<JarEntry> entries = jar.entries();
JarEntry entry;
int entryCount = 0;
while (entries.hasMoreElements()) {
entry = entries.nextElement();
if (entry.isDirectory())
continue;
String name = entry.getName();
String prefix = (name.lastIndexOf('/') >= 0)?
name.substring(0, name.lastIndexOf('/')): "";
if (prefix.startsWith("META-INF")
|| prefix.startsWith("1.0/")
|| prefix.startsWith("com/")
|| prefix.startsWith("javax/")
|| prefix.startsWith("freemarker/")
|| prefix.startsWith("org/apache/tomcat")
|| prefix.startsWith("org/apache/lucene")
|| prefix.startsWith("org/w3c/")
// || prefix.startsWith("")
|| prefix.startsWith("org/netbeans/modules/openide/actions")
|| prefix.startsWith("org/netbeans/modules/openide/awt")
|| prefix.startsWith("org/netbeans/modules/openide/windows")
|| prefix.startsWith("org/openide/explorer/propertysheet") // in deprecated core/settings
|| prefix.startsWith("org/openide/io")
|| prefix.startsWith("org/netbeans/api")
|| prefix.startsWith("org/netbeans/spi")
|| prefix.startsWith("org/netbeans/core/execution/beaninfo")
|| prefix.startsWith("org/netbeans/modules/web/monitor")
|| prefix.matches("org/netbeans/.*/[as]pi.*")
) {
continue;
}
entryCount++;
Integer count = resourcesPerPackage.get(prefix);
if (count != null) {
resourcesPerPackage.put(prefix, count+1);
}
else {
resourcesPerPackage.put(prefix, 1);
}
}
if (entryCount > 1) { // filter library wrappes (they have only Bundle.properties)
for (Map.Entry<String, Integer> pkgInfo: resourcesPerPackage.entrySet()) {
if (pkgInfo.getValue().equals(1)) {
violations.add(new Violation(pkgInfo.getKey(), jar.getName(), " has package with just one resource"));
}
}
}
}
if (!violations.isEmpty()) {
StringBuilder msg = new StringBuilder();
msg.append("Some JARs in IDE contains sparsely populated packages ("+violations.size()+"):\n");
for (Violation viol: violations) {
msg.append(viol).append('\n');
}
fail(msg.toString());
}
// assertTrue (entry.toString()+" should have line number table", v.foundLineNumberTable());
}