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


Java Map.Entry方法代码示例

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


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

示例1: toString

import java.util.Map; //导入方法依赖的package包/类
/**
 * Returns the Map as a string.
 *
 * @return the Map as a String
 */
@Override
public String toString() {
    if (isEmpty()) {
        return "{}";
    }
    final StringBuilder buf = new StringBuilder();
    buf.append('{');
    boolean first = true;
    for (final Map.Entry<K, V> entry : entrySet()) {
        final K key = entry.getKey();
        final V value = entry.getValue();
        if (first) {
            first = false;
        } else {
            buf.append(", ");
        }
        buf.append(key == this ? "(this Map)" : key);
        buf.append('=');
        buf.append(value == this ? "(this Map)" : value);
    }
    buf.append('}');
    return buf.toString();
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:ListOrderedMap.java

示例2: commandList

import java.util.Map; //导入方法依赖的package包/类
/** Returns a 2-column list with command names and the first line of their header or (if absent) description.
 * @return a usage help section describing the added commands */
public String commandList() {
    if (commands.isEmpty()) { return ""; }
    int commandLength = maxLength(commands.keySet());
    Help.TextTable textTable = new Help.TextTable(ansi(),
            new Help.Column(commandLength + 2, 2, Help.Column.Overflow.SPAN),
            new Help.Column(usageHelpWidth - (commandLength + 2), 2, Help.Column.Overflow.WRAP));

    for (Map.Entry<String, Help> entry : commands.entrySet()) {
        Help help = entry.getValue();
        CommandSpec command = help.commandSpec;
        String header = command.header() != null && command.header().length > 0 ? command.header()[0]
                : (command.description() != null && command.description().length > 0 ? command.description()[0] : "");
        textTable.addRowValues(colorScheme.commandText(entry.getKey()), ansi().new Text(header));
    }
    return textTable.toString();
}
 
开发者ID:remkop,项目名称:picocli,代码行数:19,代码来源:CommandLine.java

示例3: deserialize

import java.util.Map; //导入方法依赖的package包/类
@Override
public SetMultimap<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
	SetMultimap<String, String> map = HashMultimap.create();

	JsonObject filters = json.getAsJsonObject();
	for (Map.Entry<String, JsonElement> filter : filters.entrySet())
	{
		String name = filter.getKey();
		JsonArray values = ((JsonArray)filter.getValue());
		for (JsonElement value : values)
		{
			map.put(name, value.getAsString());
		}
	}

	return map;
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:19,代码来源:SetMultimapDeserializer.java

示例4: match

import java.util.Map; //导入方法依赖的package包/类
/**
 * 匹配url获取相应字符集
 * @param url 网址
 * @return 失败返回null
 */
public String match(String url) {
    String commonCharset = getCommonCharset();
    if (commonCharset != null) {
        return commonCharset;
    }
    String host = SpiderUrlUtils.getUrlHost(url);
    if (host != null) {
        for (Map.Entry<String, String> entry : charsets.entrySet()) {
            if (host.contains(entry.getKey())) {
                return entry.getValue();
            }
        }
    }
    return null;
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:21,代码来源:Charsets.java

示例5: verifySize

import java.util.Map; //导入方法依赖的package包/类
public static void verifySize(String regionName, int noOfElememts, int entrySize) {
  final Region pr = cache.getRegion(regionName);
  for (final Iterator i =
      ((PartitionedRegion) pr).getDataStore().getAllLocalBuckets().iterator(); i.hasNext();) {
    final Map.Entry entry = (Map.Entry) i.next();
    final BucketRegion bucketRegion = (BucketRegion) entry.getValue();
    if (bucketRegion == null) {
      continue;
    } else {
      AbstractLRURegionMap map = (AbstractLRURegionMap) bucketRegion.entries;
      if (map == null || map.size() == 0) {
        continue;
      }
      LogWriterUtils.getLogWriter().info("Checking for entry in bucket region: " + bucketRegion);
      for (int counter = 1; counter <= noOfElememts; counter++) {
        assertEquals(entrySize,
            ((AbstractLRURegionEntry) map.getEntry(new Integer(counter))).getEntrySize());
      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:EvictionObjectSizerDUnitTest.java

示例6: addParameters

import java.util.Map; //导入方法依赖的package包/类
/**
* Add parameters to a new url.
* 
* @param parameters
* @return A new URL 
*/
  public URL addParameters(Map<String, String> parameters) {
      if (parameters == null || parameters.size() == 0) {
          return this;
      }

      boolean hasAndEqual = true;
      for(Map.Entry<String, String> entry : parameters.entrySet()) {
          String value = getParameters().get(entry.getKey());
          if(value == null && entry.getValue() != null || !value.equals(entry.getValue())) {
              hasAndEqual = false;
              break;
          }
      }
      // 如果没有修改,直接返回。
      if(hasAndEqual) return this;

      Map<String, String> map = new HashMap<String, String>(getParameters());
      map.putAll(parameters);
      return new URL(protocol, username, password, host, port, path, map);
  }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:27,代码来源:URL.java

示例7: containsValue

import java.util.Map; //导入方法依赖的package包/类
@Override
public boolean containsValue(Object value) {
    if (value == null) {
        throw new NullPointerException();
    }

    for (Map.Entry<K, CachedValue<K, V>> entry : map.entrySet()) {
        CachedValue<K, V> cachedValue = entry.getValue();
        if (cachedValue.getValue().equals(value)) {
            if (isValueExpired(cachedValue)) {
                if (map.remove(cachedValue.getKey(), cachedValue)) {
                    onValueRemove(cachedValue);
                }
            } else {
                readValue(cachedValue);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:22,代码来源:AbstractCacheMap.java

示例8: uri

import java.util.Map; //导入方法依赖的package包/类
static String uri(final URI apiHost,
                  final Map<String, List<String>> parameters,
                  final String... segments) {
  final Builder builder = builder(apiHost, segments);
  for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
    for (String value : entry.getValue()) {
      builder.addQueryParameter(entry.getKey(), value);
    }
  }
  return builder.build().toString();
}
 
开发者ID:honnix,项目名称:rkt-launcher,代码行数:12,代码来源:RktCommandHelper.java

示例9: properties2String

import java.util.Map; //导入方法依赖的package包/类
public static String properties2String(final Properties properties) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        if (entry.getValue() != null) {
            sb.append(entry.getKey().toString())
                    .append("=").append(entry.getValue().toString())
                    .append("\n");
        }
    }
    return sb.toString();
}
 
开发者ID:weiboad,项目名称:fiery,代码行数:12,代码来源:Toolbox.java

示例10: findAddressesByService

import java.util.Map; //导入方法依赖的package包/类
public List<String> findAddressesByService(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(null == consumerUrls) return ret;
    
    for(Map.Entry<Long, URL> e2 : consumerUrls.get(service).entrySet()) {
        URL u = e2.getValue();
        String app = u.getAddress();
        if(app != null) ret.add(app);
    }
    
    return ret;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:14,代码来源:ConsumerServiceImpl.java

示例11: mergeWRSLatencies

import java.util.Map; //导入方法依赖的package包/类
public static WRSLatency mergeWRSLatencies(WRSLatency[] latencies) {
  WRSLatency ret = new WRSLatency();
  for (WRSLatency src : latencies) {
    // merge write latency
    if (src == null) {
      new RuntimeException("meet WRSLatency null").printStackTrace();
      continue;
    }
    for (int i = 0; i < src.writeStatistics.latencyBoxNumbers.length; i++) {
      ret.writeStatistics.latencyBoxNumbers[i] += src.writeStatistics.latencyBoxNumbers[i];
    }
    ret.writeStatistics.totalLatency += src.writeStatistics.totalLatency;
    ret.writeStatistics.totalCount += src.writeStatistics.totalCount;
    ret.writeStatistics.maxLatency =
        Math.max(ret.writeStatistics.maxLatency, src.writeStatistics.maxLatency);
    // merge read latency
    for (int i = 0; i < src.readStatistics.latencyBoxNumbers.length; i++) {
      ret.readStatistics.latencyBoxNumbers[i] += src.readStatistics.latencyBoxNumbers[i];
    }
    ret.readStatistics.totalLatency += src.readStatistics.totalLatency;
    ret.readStatistics.totalCount += src.readStatistics.totalCount;
    ret.readStatistics.maxLatency =
        Math.max(ret.readStatistics.maxLatency, src.readStatistics.maxLatency);
    // merge scan latency
    for (Map.Entry<String, Long> entry : src.scanTimes.entrySet()) {
      long prevTime =
          ret.scanTimes.containsKey(entry.getKey()) ? ret.scanTimes.get(entry.getKey()) : 0;
      long prevCount =
          ret.scanCounts.containsKey(entry.getKey()) ? ret.scanCounts.get(entry.getKey()) : 0;
      ret.scanTimes.put(entry.getKey(), prevTime + entry.getValue());
      ret.scanCounts.put(entry.getKey(), prevCount + src.scanCounts.get(entry.getKey()));
    }
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:LatencyStatistics.java

示例12: getSourceLevel

import java.util.Map; //导入方法依赖的package包/类
@Override
public Result getSourceLevel(FileObject javaFile) {
    for (Map.Entry<FileObject,R> e : this.levels.entrySet()) {
        final FileObject root = e.getKey();
        if (root.equals(javaFile) || FileUtil.isParentOf(root, javaFile)) {
            return e.getValue();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DefaultClassPathProviderTest.java

示例13: unmodifiableMultiValueMap

import java.util.Map; //导入方法依赖的package包/类
/**
 * Return an unmodifiable view of the specified multi-value map.
 * 
 * @param map
 *        the map for which an unmodifiable view is to be returned.
 * @return an unmodifiable view of the specified multi-value map.
 * @since 3.1
 */
public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
	Assert.notNull(map, "'map' must not be null");
	Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size());
	for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) {
		List<V> values = Collections.unmodifiableList(entry.getValue());
		result.put(entry.getKey(), values);
	}
	Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
	return toMultiValueMap(unmodifiableMap);
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:19,代码来源:CollectionUtils.java

示例14: putAll

import java.util.Map; //导入方法依赖的package包/类
@Override
public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
  boolean changed = false;
  for (Map.Entry<? extends K, ? extends V> entry : multimap.entries()) {
    changed |= put(entry.getKey(), entry.getValue());
  }
  return changed;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:AbstractMultimap.java

示例15: getNameTest

import java.util.Map; //导入方法依赖的package包/类
@Test
public void getNameTest() {
    for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
        String expected = e.getKey().getName();
        String actual = e.getValue().getName();
        assertEquals(expected, actual);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TestJavaMethod.java


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