本文整理了Java中java.util.concurrent.ConcurrentHashMap.values()
方法的一些代码示例,展示了ConcurrentHashMap.values()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.values()
方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:values
[英]Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from this map, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
The view's iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.
[中]返回此映射中包含的值的集合视图。集合由映射支持,因此对映射的更改将反映在集合中,反之亦然。集合支持元素移除,通过迭代器从映射中移除相应的映射。移除、收集。移除、移除所有、保留和清除操作。它不支持添加或添加所有操作。
视图的迭代器是一个“弱一致性”迭代器,它永远不会抛出ConcurrentModificationException,并保证在构造迭代器时遍历元素,并且可能(但不保证)反映构造之后的任何修改。
代码示例来源:origin: neo4j/neo4j
@Override
public Iterator<T> iterator()
{
return cache.values().iterator();
}
}
代码示例来源:origin: Alluxio/alluxio
@Override
public Iterator<T> iterator() {
return mIndexMap.values().iterator();
}
代码示例来源:origin: org.apache.commons/commons-math3
/**
* {@inheritDoc}
*/
public Iterator<Neuron> iterator() {
return neuronMap.values().iterator();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Resets all labels and remove invalid ones.
*
* This should be called when the assumptions behind label cache computation changes,
* but we also call this periodically to self-heal any data out-of-sync issue.
*/
/*package*/ void trimLabels() {
for (Iterator<Label> itr = labels.values().iterator(); itr.hasNext();) {
Label l = itr.next();
resetLabel(l);
if(l.isEmpty())
itr.remove();
}
}
代码示例来源:origin: ben-manes/caffeine
EntryIterator(BoundedLocalCache<K, V> cache) {
this.iterator = cache.data.values().iterator();
this.now = cache.expirationTicker().read();
this.cache = cache;
}
代码示例来源:origin: k9mail/k-9
public void stopAllPushing() {
Timber.i("Stopping all pushers");
Iterator<Pusher> iter = pushers.values().iterator();
while (iter.hasNext()) {
Pusher pusher = iter.next();
iter.remove();
pusher.stop();
}
}
代码示例来源:origin: brianfrankcooper/YCSB
@Override
public void cleanup() throws DBException {
try {
Iterator<BatchWriter> iterator = writers.values().iterator();
while (iterator.hasNext()) {
BatchWriter writer = iterator.next();
writer.close();
iterator.remove();
}
} catch (MutationsRejectedException e) {
throw new DBException(e);
}
}
代码示例来源:origin: brianfrankcooper/YCSB
@Override
public void cleanup() throws DBException {
try {
Iterator<BatchWriter> iterator = writers.values().iterator();
while (iterator.hasNext()) {
BatchWriter writer = iterator.next();
writer.close();
iterator.remove();
}
} catch (MutationsRejectedException e) {
throw new DBException(e);
}
}
代码示例来源:origin: brianfrankcooper/YCSB
@Override
public void cleanup() throws DBException {
try {
Iterator<BatchWriter> iterator = writers.values().iterator();
while (iterator.hasNext()) {
BatchWriter writer = iterator.next();
writer.close();
iterator.remove();
}
} catch (MutationsRejectedException e) {
throw new DBException(e);
}
}
代码示例来源:origin: apache/geode
public static void logInstantiators() {
for (Iterator itr = dsMap.values().iterator(); itr.hasNext();) {
Instantiator instantiator = (Instantiator) itr.next();
logger
.info("Instantiator registered with id {} class {}",
Integer.valueOf(instantiator.getId()),
instantiator.getInstantiatedClass().getName());
}
for (Iterator itr = idsToHolders.values().iterator(); itr.hasNext();) {
InstantiatorAttributesHolder holder = (InstantiatorAttributesHolder) itr.next();
logger.info("Instantiator registered with holder id {} class {}",
Integer.valueOf(holder.getId()), holder.getInstantiatedClassName());
}
}
}
代码示例来源:origin: orbit/orbit
private void doViewAccepted(final View view)
{
final ConcurrentHashMap<Address, NodeInfo> newNodes = new ConcurrentHashMap<>(view.size());
final ConcurrentHashMap<NodeAddress, NodeInfo> newNodes2 = new ConcurrentHashMap<>(view.size());
for (final Address a : view)
{
NodeInfo info = nodeMap.get(a);
if (info == null)
{
info = new NodeInfo(a);
}
newNodes.put(a, info);
newNodes2.put(info.nodeAddress, info);
}
final NodeInfo newMaster = newNodes.values().iterator().next();
nodeMap.putAll(newNodes);
nodeMap.values().retainAll(newNodes.values());
nodeMap2.putAll(newNodes2);
nodeMap2.values().retainAll(newNodes2.values());
master = newMaster;
viewListener.onViewChange(nodeMap2.keySet());
}
代码示例来源:origin: com.h2database/h2
private synchronized void freeUnusedChunks() {
if (lastChunk == null || !reuseSpace) {
return;
}
Set<Integer> referenced = collectReferencedChunks();
long time = getTimeSinceCreation();
for (Iterator<Chunk> it = chunks.values().iterator(); it.hasNext(); ) {
Chunk c = it.next();
if (!referenced.contains(c.id)) {
if (canOverwriteChunk(c, time)) {
it.remove();
markMetaChanged();
meta.remove(Chunk.getMetaKey(c.id));
long start = c.block * BLOCK_SIZE;
int length = c.len * BLOCK_SIZE;
fileStore.free(start, length);
} else {
if (c.unused == 0) {
c.unused = time;
meta.put(Chunk.getMetaKey(c.id), c.asString());
markMetaChanged();
}
}
}
}
}
代码示例来源:origin: apache/geode
Collection coll = new ArrayList();
if (!classNamesToHolders.isEmpty()) {
Iterator it = classNamesToHolders.values().iterator();
while (it.hasNext()) {
try {
代码示例来源:origin: ben-manes/caffeine
await().untilTrue(writing);
Node<Integer, Integer> node = localCache.data.values().iterator().next();
localCache.evictEntry(node, RemovalCause.SIZE, 0L);
代码示例来源:origin: ebean-orm/ebean
/**
* Trim query plans not used since the passed in epoch time.
*/
public List<CQueryPlan> trimQueryPlans(long unusedSince) {
List<CQueryPlan> list = new ArrayList<>();
Iterator<CQueryPlan> it = queryPlanCache.values().iterator();
while (it.hasNext()) {
CQueryPlan queryPlan = it.next();
if (queryPlan.getLastQueryTime() < unusedSince) {
it.remove();
list.add(queryPlan);
}
}
return list;
}
代码示例来源:origin: i2p/i2p.i2p
private void expireOutbound() {
for (Iterator<LocalAddress> iter = _outgoing.values().iterator(); iter.hasNext(); ) {
LocalAddress a = iter.next();
if (a.expire < getTunnel().getContext().clock().now())
iter.remove();
}
for (Iterator<LocalAddress> iter = _active.values().iterator(); iter.hasNext(); ) {
LocalAddress a = iter.next();
I2PSocket s = a.socket;
if (s != null && s.isClosed())
iter.remove();
}
}
代码示例来源:origin: i2p/i2p.i2p
/**
* Remove expired nonces from map
* @since 0.9.6
*/
private void cleanNonces() {
long now = _context.clock().now();
for (Iterator<NonceInfo> iter = _nonces.values().iterator(); iter.hasNext(); ) {
NonceInfo info = iter.next();
if (info.getExpires() <= now)
iter.remove();
}
}
代码示例来源:origin: com.github.ben-manes.caffeine/caffeine
EntryIterator(BoundedLocalCache<K, V> cache) {
this.iterator = cache.data.values().iterator();
this.now = cache.expirationTicker().read();
this.cache = cache;
}
代码示例来源:origin: i2p/i2p.i2p
/**
* Something b0rked hard, so kill all of our connections without mercy.
* Don't bother sending close packets.
* This will not close the ServerSocket.
* This will not kill the timer threads.
*
* CAN continue to use the manager.
*/
public void disconnectAllHard() {
//if (_log.shouldLog(Log.INFO))
// _log.info("ConnMan hard disconnect", new Exception("I did it"));
for (Iterator<Connection> iter = _connectionByInboundId.values().iterator(); iter.hasNext(); ) {
Connection con = iter.next();
con.disconnect(false, false);
iter.remove();
}
synchronized(_recentlyClosed) {
_recentlyClosed.clear();
}
_pendingPings.clear();
// FIXME
// Ideally we would like to stop all TCBShare and all the timer threads here,
// but leave them ready to restart when things resume.
// However that's quite difficult.
// So the timer threads will continue to run.
}
代码示例来源:origin: i2p/i2p.i2p
/** @since 0.9.2 */
private void doFailsafe() {
for (Iterator<OutboundEstablishState> iter = _liveIntroductions.values().iterator(); iter.hasNext(); ) {
OutboundEstablishState state = iter.next();
if (state.getLifetime() > 3*MAX_OB_ESTABLISH_TIME) {
iter.remove();
if (_log.shouldLog(Log.WARN))
_log.warn("Failsafe remove LI " + state);
}
}
for (Iterator<OutboundEstablishState> iter = _outboundByClaimedAddress.values().iterator(); iter.hasNext(); ) {
OutboundEstablishState state = iter.next();
if (state.getLifetime() > 3*MAX_OB_ESTABLISH_TIME) {
iter.remove();
if (_log.shouldLog(Log.WARN))
_log.warn("Failsafe remove OBBCA " + state);
}
}
for (Iterator<OutboundEstablishState> iter = _outboundByHash.values().iterator(); iter.hasNext(); ) {
OutboundEstablishState state = iter.next();
if (state.getLifetime() > 3*MAX_OB_ESTABLISH_TIME) {
iter.remove();
if (_log.shouldLog(Log.WARN))
_log.warn("Failsafe remove OBBH " + state);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!