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


Java ConcurrentHashMap.entrySet方法代码示例

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


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

示例1: writeTable

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/** CURRENTLY UNTESTED! NEED TO REPLICATE THIS IN THE READING OF THE FILE AS WELL
 * This method will write the table specified by the internal parents
 * protected mTableName field.
 *
 * @param controller The configuration controller in order to gain
 *                   access to a specified resource file.
 */
@Override
public void writeTable (ConfigController controller)
{
    YamlConfiguration wageTable = controller.getSpecialConfig (mTableName.getFileName ());

    for (Map.Entry<String, ConcurrentHashMap<String, BigDecimal>> tableEntry : mBlockMap.entrySet ())
    {
        ConcurrentHashMap<String, BigDecimal> tableMap = tableEntry.getValue ();
        ConcurrentHashMap<String, BigDecimal> blockMapSection = mBlockMap.get (tableEntry.getKey ());

        for (Map.Entry<String, BigDecimal> entry : tableMap.entrySet ())
        {
            wageTable.set (tableEntry.getKey () + "." + entry.getKey (), blockMapSection.get (entry.getKey ()));
        }
    }

    controller.saveConfig (wageTable, mTableName.getFileName ());
}
 
开发者ID:MagnaRisa,项目名称:CraftyProfessions,代码行数:26,代码来源:BlockTable.java

示例2: buildQueryParameter

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * add requestParams to query parameter for url
 * */
HttpUrl buildQueryParameter() {
    if (requestParams == null) {
        return url;
    }

    final ConcurrentHashMap<String, String> urlParams = requestParams.urlParams;
    HttpUrl.Builder builder = url.newBuilder();
    for (Map.Entry<String, String> entry : urlParams.entrySet()) {
        builder.addQueryParameter(entry.getKey(), entry.getValue());
    }

    url = builder.build();
    return url;

}
 
开发者ID:JarvanMo,项目名称:MarsBootProject,代码行数:19,代码来源:ParametersCreator.java

示例3: isTargetRegistered

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * Is target registered.
 *
 * @param targetObject    the target object.
 * @param targetChannelId the target channel id.
 * @return is target registered.
 */
private boolean isTargetRegistered(Object targetObject, List<String> targetChannelId) {
    Set<String> currentlyRegisteredChannelId = new HashSet<>();
    for (Map.Entry<Class<?>, ConcurrentHashMap<Object, ConcurrentHashMap<String,
            SubscriberHolder>>> mEventsToTargetsMapEntry : mEventsToTargetsMap.entrySet()) {
        ConcurrentHashMap<Object, ConcurrentHashMap<String, SubscriberHolder>> mTargetMap =
                mEventsToTargetsMapEntry.getValue();
        if (mTargetMap.containsKey(targetObject)) {
            ConcurrentHashMap<String, SubscriberHolder> subscribeMethods = mTargetMap.get
                    (targetObject);
            for (Map.Entry<String, SubscriberHolder> subscribeMethodEntry : subscribeMethods.entrySet()) {
                for (String methodChannelID : subscribeMethodEntry.getValue().subscribedChannelID) {
                    currentlyRegisteredChannelId.add(methodChannelID);

                }
            }
        }
    }
    return currentlyRegisteredChannelId.size() > 0 && currentlyRegisteredChannelId.containsAll(targetChannelId);
}
 
开发者ID:MindorksOpenSource,项目名称:NYBus,代码行数:27,代码来源:NYBusDriver.java

示例4: testEntrySet

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * entrySet contains all pairs
 */
public void testEntrySet() {
    ConcurrentHashMap map = map5();
    Set s = map.entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue(
                   (e.getKey().equals(one) && e.getValue().equals("A")) ||
                   (e.getKey().equals(two) && e.getValue().equals("B")) ||
                   (e.getKey().equals(three) && e.getValue().equals("C")) ||
                   (e.getKey().equals(four) && e.getValue().equals("D")) ||
                   (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ConcurrentHashMapTest.java

示例5: main

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    final ConcurrentHashMap<String, String> concurrentHashMap =
        new ConcurrentHashMap<>();

    concurrentHashMap.put("One", "Un");
    concurrentHashMap.put("Two", "Deux");
    concurrentHashMap.put("Three", "Trois");

    Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet();
    HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet);

    if (false == hashSet.equals(entrySet)) {
        throw new RuntimeException("Test FAILED: Sets are not equal.");
    }
    if (hashSet.hashCode() != entrySet.hashCode()) {
        throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DistinctEntrySetElements.java

示例6: writeTransform

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Override
public Object writeTransform(Field f, Class<?> clazz, Object originalValue) {
  if (f.getType().equals(ConcurrentHashMap.class)) {
    Object[] result = null;
    if (originalValue != null) {
      ConcurrentHashMap<?, ?> m = (ConcurrentHashMap<?, ?>) originalValue;
      result = new Object[m.size() * 2];
      int i = 0;
      for (Map.Entry<?, ?> e : m.entrySet()) {
        result[i++] = e.getKey();
        result[i++] = e.getValue();
      }
    }
    return result;
  } else {
    return super.writeTransform(f, clazz, originalValue);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:AutoSerializableJUnitTest.java

示例7: getSlowQueriesCD

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * JMX operation - returns all the queries we have collected.
 * @return - the slow query report as composite data.
 */
@Override
public CompositeData[] getSlowQueriesCD() throws OpenDataException {
    CompositeDataSupport[] result = null;
    ConcurrentHashMap<String,QueryStats> queries = perPoolStats.get(poolName);
    if (queries!=null) {
        Set<Map.Entry<String,QueryStats>> stats = queries.entrySet();
        if (stats!=null) {
            result = new CompositeDataSupport[stats.size()];
            Iterator<Map.Entry<String,QueryStats>> it = stats.iterator();
            int pos = 0;
            while (it.hasNext()) {
                Map.Entry<String,QueryStats> entry = it.next();
                QueryStats qs = entry.getValue();
                result[pos++] = qs.getCompositeData(getCompositeType());
            }
        }
    }
    return result;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:SlowQueryReportJmx.java

示例8: checkCloseChannel

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * 检查 关闭的channel
 * 
 * @param channelMap
 */
private void checkCloseChannel(ConcurrentHashMap<String, List<ChannelWrapper>> channelMap) {
    for (Map.Entry<String, List<ChannelWrapper>> entry : channelMap.entrySet()) {
        List<ChannelWrapper> channels = entry.getValue();
        List<ChannelWrapper> removeList = new ArrayList<ChannelWrapper>();
        for (ChannelWrapper channel : channels) {
            if (channel.isClosed()) {
                removeList.add(channel);
                logger.info(String.format("close channel=%s", channel));
            }
        }
        channels.removeAll(removeList);
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:19,代码来源:ChannelManager.java

示例9: SessionTrackerImpl

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public SessionTrackerImpl(SessionExpirer expirer,
        ConcurrentHashMap<Long, Integer> sessionsWithTimeout, int tickTime,
        long sid, ZooKeeperServerListener listener)
{
    super("SessionTracker", listener);
    this.expirer = expirer;
    this.expirationInterval = tickTime;
    this.sessionsWithTimeout = sessionsWithTimeout;
    nextExpirationTime = roundToInterval(System.currentTimeMillis());
    this.nextSessionId = initializeNextSession(sid);
    for (Entry<Long, Integer> e : sessionsWithTimeout.entrySet()) {
        addSession(e.getKey(), e.getValue());
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:15,代码来源:SessionTrackerImpl.java

示例10: testEntrySetToArray

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * entrySet.toArray contains all entries
 */
public void testEntrySetToArray() {
    ConcurrentHashMap map = map5();
    Set s = map.entrySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    for (int i = 0; i < 5; ++i) {
        assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
        assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentHashMapTest.java

示例11: getHourDetail

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
public TreeMap<Long, APIStatisticStruct> getHourDetail(String url, Long shardtime) {
    TreeMap<Long, APIStatisticStruct> urlStatics = new TreeMap<>();

    if (apiTopHourStaticHelper.containsKey(url)) {
        //return apiTopHourStaticHelper.get(url);
        ConcurrentHashMap<Long, APIStatisticStruct> staticsSet = apiTopHourStaticHelper.get(url);

        for (Map.Entry<Long, APIStatisticStruct> statisticItem : staticsSet.entrySet()) {
            if (statisticItem.getKey() >= shardtime && statisticItem.getKey() <= shardtime + 86400) {
                urlStatics.put(DateTimeHelper.getHour(statisticItem.getKey()), statisticItem.getValue());
            }
        }
    }
    return urlStatics;
}
 
开发者ID:weiboad,项目名称:fiery,代码行数:16,代码来源:APIStatisticTimeSet.java

示例12: sendCachedCalls

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
private void sendCachedCalls(final String tag) {
    ConcurrentHashMap<UUID, CacheCallData> cacheCalls = mTaggedCacheCalls.get(tag);
    if (cacheCalls == null) return;

    for (final Map.Entry<UUID, CacheCallData> callData : cacheCalls.entrySet()) {
        sendCachedCall(tag, callData.getKey(), callData.getValue());
    }
}
 
开发者ID:metarhia,项目名称:metacom-android,代码行数:9,代码来源:AndroidJSTPConnection.java

示例13: testHashCode

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * hashCode() equals sum of each key.hashCode ^ value.hashCode
 */
public void testHashCode() {
    ConcurrentHashMap<Integer,String> map = map5();
    int sum = 0;
    for (Map.Entry<Integer,String> e : map.entrySet())
        sum += e.getKey().hashCode() ^ e.getValue().hashCode();
    assertEquals(sum, map.hashCode());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentHashMapTest.java

示例14: writeConcurrentHashMap

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
/**
 * Writes a <code>ConcurrentHashMap</code> to a <code>DataOutput</code>. Note that even though
 * <code>map</code> may be an instance of a subclass of <code>ConcurrentHashMap</code>,
 * <code>readConcurrentHashMap</code> will always return an instance of
 * <code>ConcurrentHashMap</code>, <B>not</B> an instance of the subclass. To preserve the class
 * type of <code>map</code>, {@link #writeObject(Object, DataOutput)} should be used for data
 * serialization.
 * <P>
 * At this time if {@link #writeObject(Object, DataOutput)} is called with an instance of
 * ConcurrentHashMap then it will be serialized with normal java.io Serialization. So if you want
 * the keys and values of a ConcurrentHashMap to take advantage of GemFire serialization it must
 * be serialized with this method.
 *
 * @throws IOException A problem occurs while writing to <code>out</code>
 *
 * @see #readConcurrentHashMap
 * @since GemFire 6.6
 */
public static void writeConcurrentHashMap(ConcurrentHashMap<?, ?> map, DataOutput out)
    throws IOException {

  InternalDataSerializer.checkOut(out);

  int size;
  Collection<Map.Entry<?, ?>> entrySnapshot = null;
  if (map == null) {
    size = -1;
  } else {
    // take a snapshot to fix bug 44562
    entrySnapshot = new ArrayList<Map.Entry<?, ?>>(map.entrySet());
    size = entrySnapshot.size();
  }
  InternalDataSerializer.writeArrayLength(size, out);
  if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
    logger.trace(LogMarker.SERIALIZER, "Writing ConcurrentHashMap with {} elements: {}", size,
        entrySnapshot);
  }
  if (size > 0) {
    for (Map.Entry<?, ?> entry : entrySnapshot) {
      writeObject(entry.getKey(), out);
      writeObject(entry.getValue(), out);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:45,代码来源:DataSerializer.java

示例15: disconnected

import java.util.concurrent.ConcurrentHashMap; //导入方法依赖的package包/类
@Override
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
    @SuppressWarnings("unchecked")
    ConcurrentHashMap<CacheKey,CachedStatement> statements =
        (ConcurrentHashMap<CacheKey,CachedStatement>)con.getAttributes().get(STATEMENT_CACHE_ATTR);

    if (statements!=null) {
        for (Map.Entry<CacheKey, CachedStatement> p : statements.entrySet()) {
            closeStatement(p.getValue());
        }
        statements.clear();
    }

    super.disconnected(parent, con, finalizing);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:16,代码来源:StatementCache.java


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