java.util.IdentityHashMap.values()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中java.util.IdentityHashMap.values()方法的一些代码示例,展示了IdentityHashMap.values()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentityHashMap.values()方法的具体详情如下:
包路径:java.util.IdentityHashMap
类名称:IdentityHashMap
方法名:values

IdentityHashMap.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. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear methods. It does not support the add or addAll methods.

While the object returned by this method implements the Collection interface, it does not obey Collection's general contract. Like its backing map, the collection returned by this method defines element equality as reference-equality rather than object-equality. This affects the behavior of its contains, remove and containsAll methods.
[中]返回此映射中包含的值的集合视图。集合由映射支持,因此对映射的更改将反映在集合中,反之亦然。如果在集合上进行迭代时修改了映射,则迭代的结果是未定义的。集合支持元素移除,通过迭代器从映射中移除相应的映射。移除、收集。移除、移除所有、保留和清除方法。它不支持add或addAll方法。
虽然此方法返回的对象实现了集合接口,但它不遵守集合的一般约定。与其后台映射一样,此方法返回的集合将元素相等定义为引用相等而不是对象相等。这会影响其contains、remove和containsAll方法的行为。

代码示例

代码示例来源:origin: wildfly/wildfly

Collection<ProxyMethodInfo> getMethods() {
  return methodInfoMap.values();
}

代码示例来源:origin: requery/requery

@Override @Nonnull
public Collection<V> values() {
  return map.values();
}

代码示例来源:origin: spotbugs/spotbugs

/**
 * Get an iterator over the result facts.
 */
public Iterator<Fact> resultFactIterator() {
  return resultFactMap.values().iterator();
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

private void writeObject(ObjectOutputStream out) throws IOException {
  for (List<Edge> le : outgoing.values())
    ((ArrayList<Edge>)le).trimToSize();
  for (List<Edge> le : incoming.values())
    ((ArrayList<Edge>)le).trimToSize();
  out.defaultWriteObject();
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * A single edge can appear once or twice. (CH graphs might have only outgoing or only incoming
 * edges.) Avoid double-counting.
 */
public int countEdges() {
  HashSet<Edge> eset = new HashSet<Edge>(1000);
  for (List<Edge> l : outgoing.values())
    for (Edge e : l)
      eset.add(e);
  for (List<Edge> l : incoming.values())
    for (Edge e : l)
      eset.add(e);
  return eset.size();
}

代码示例来源:origin: apache/geode

@Override
public int getChanges() {
 int changes = 0;
 Iterator<TXRegionState> it = this.regions.values().iterator();
 while (it.hasNext()) {
  TXRegionState txrs = it.next();
  changes += txrs.getChanges();
 }
 return changes;
}

代码示例来源:origin: google/ExoPlayer

@Override
public void stop() {
 primaryHlsUrl = null;
 primaryUrlSnapshot = null;
 masterPlaylist = null;
 initialStartTimeUs = C.TIME_UNSET;
 initialPlaylistLoader.release();
 initialPlaylistLoader = null;
 for (MediaPlaylistBundle bundle : playlistBundles.values()) {
  bundle.release();
 }
 playlistRefreshHandler.removeCallbacksAndMessages(null);
 playlistRefreshHandler = null;
 playlistBundles.clear();
}

代码示例来源:origin: apache/geode

public void setDistTxEntryStates(ArrayList<ArrayList<DistTxThinEntryState>> entryEventList) {
  TreeMap<String, TXRegionState> regionSortedMap = new TreeMap<>();
  for (TXRegionState txrs : this.regions.values()) {
   if (txrs.isCreatedDuringCommit()) {
    regionSortedMap.put(txrs.getRegion().getFullPath(), txrs);
   }
  }

  int index = 0;
  for (Entry<String, TXRegionState> me : regionSortedMap.entrySet()) {
   String regionFullPath = me.getKey();
   TXRegionState txrs = me.getValue();
   ArrayList<DistTxThinEntryState> entryEvents = entryEventList.get(index++);
   if (logger.isDebugEnabled()) {
    logger.debug("DistTxState.setDistTxEntryStates For region=" + regionFullPath + " ,index="
      + index + " ,entryEvents=(" + entryEvents.size() + ")=" + entryEvents
      + " ,regionSortedMap=" + regionSortedMap.keySet());
   }
   txrs.setDistTxEntryStates(entryEvents);
  }
 }
}

代码示例来源:origin: apache/ignite

/**
 * @return All known cache IDs.
 */
public Collection<Integer> cacheIds() {
  ArrayList<Integer> res = new ArrayList<>(1);
  for (Object o : h2ObjToGridObj.values()) {
    if (o instanceof GridSqlAlias)
      o = GridSqlAlias.unwrap((GridSqlAst)o);
    if (o instanceof GridSqlTable) {
      GridH2Table tbl = ((GridSqlTable)o).dataTable();
      if (tbl != null)
        res.add(tbl.cacheId());
    }
  }
  return res;
}

代码示例来源:origin: immutables/immutables

LongPositions(Iterable<? extends Object> elements, final int bitPerLong) {
 this.elements = ImmutableList.copyOf(elements);
 checkArgument(bitPerLong <= BITS_IN_LONG, bitPerLong);
 for (int i = 0; i < this.elements.size(); i++) {
  positions.put(
    this.elements.get(i),
    new BitPosition(
      i / bitPerLong,
      i % bitPerLong));
 }
 this.longPositions = ImmutableSortedMap.copyOf(
   Maps.transformEntries(
     Multimaps.index(positions.values(), ToLongIndex.FUNCTION).asMap(),
     new Maps.EntryTransformer<Integer, Collection<BitPosition>, LongSet>() {
      @Override
      public LongSet transformEntry(Integer key, Collection<BitPosition> position) {
       return new LongSet(key, position);
      }
     }));
}

代码示例来源:origin: apache/geode

/**
 * Note that cleanup does more than is needed in this method. This method only needs to do stuff
 * that is required when a Cache close is done and we have txs that are still in progress.
 * Currently the only thing that is needed is to decrement off-heap refcounts since off-heap
 * memory lives after a cache close.
 */
@Override
public void close() {
 if (!this.closed) {
  if (locks != null) {
   cleanup();
   return;
  }
  this.closed = true;
  for (TXRegionState r : this.regions.values()) {
   r.close();
  }
 }
}

代码示例来源:origin: apache/geode

@Override
public Set getAdditionalKeysForIterator(LocalRegion currRgn) {
 if (currRgn instanceof PartitionedRegion) {
  final HashSet ret = new HashSet();
  for (TXRegionState rs : this.regions.values()) {
   if (rs instanceof TXBucketRegionState) {
    TXBucketRegionState brs = (TXBucketRegionState) rs;
    if (brs.getPartitionedRegion() == currRgn) {
     brs.fillInCreatedEntryKeys(ret);
    }
   }
  }
  return ret;
 } else {
  TXRegionState txr = txReadRegion(currRgn);
  if (txr != null) {
   final HashSet ret = new HashSet();
   txr.fillInCreatedEntryKeys(ret);
   return ret;
  } else {
   return null;
  }
 }
}

代码示例来源:origin: apache/drill

/**
  * Can only be called when you already hold the writeLock.
  */
 public void release() {
  allocator.assertOpen();
  final BufferLedger oldLedger = map.remove(allocator);
  oldLedger.allocator.dissociateLedger(oldLedger);
  if (oldLedger == owningLedger) {
   if (map.isEmpty()) {
    // no one else owns, lets release.
    oldLedger.allocator.releaseBytes(size);
    underlying.release();
    amDestructionTime = System.nanoTime();
    owningLedger = null;
   } else {
    // we need to change the owning allocator. we've been removed so we'll get whatever is top of list
    BufferLedger newLedger = map.values().iterator().next();
    // we'll forcefully transfer the ownership and not worry about whether we exceeded the limit
    // since this consumer can't do anything with this.
    oldLedger.transferBalance(newLedger);
   }
  } else {
   if (map.isEmpty()) {
    throw new IllegalStateException("The final removal of a ledger should be connected to the owning ledger.");
   }
  }
 }
}

代码示例来源:origin: apache/ignite

/**
 * Get first (i.e. random, as we need any one) partitioned cache from parsed query
 *     to determine expected query parallelism.
 * @return Context for the first of partitioned caches mentioned in the query,
 *     or {@code null} if it does not involve partitioned caches.
 */
public GridCacheContext getFirstPartitionedCache() {
  for (Object o : h2ObjToGridObj.values()) {
    if (o instanceof GridSqlAlias)
      o = GridSqlAlias.unwrap((GridSqlAst)o);
    if (o instanceof GridSqlTable) {
      GridH2Table tbl = ((GridSqlTable)o).dataTable();
      if (tbl != null && tbl.cacheContext().isPartitioned())
        return tbl.cacheContext();
    }
  }
  return null;
}

代码示例来源:origin: apache/ignite

/**
 * Check if query may be run locally on all caches mentioned in the query.
 *
 * @return {@code true} if query may be run locally on all caches mentioned in the query, i.e. there's no need
 *     to run distributed query.
 */
public boolean isLocalQuery() {
  if (selectForUpdate)
    return false;
  for (Object o : h2ObjToGridObj.values()) {
    if (o instanceof GridSqlAlias)
      o = GridSqlAlias.unwrap((GridSqlAst)o);
    if (o instanceof GridSqlTable) {
      GridH2Table tbl = ((GridSqlTable)o).dataTable();
      if (tbl != null) {
        //It's not affinity cache. Can't be local.
        if (tbl.cacheContext() == null)
          return false;
        GridCacheContext cctx = tbl.cacheContext();
        if (cctx.mvccEnabled())
          return false;
        if (cctx.isPartitioned())
          return false;
        if (cctx.isReplicated() && !cctx.isReplicatedAffinityNode())
          return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: protostuff/protostuff

assertTrue(bean.identityMap.size() == 1);
assertTrue(bean.identityMap.keySet().iterator().next() == bean.identityMap
    .values().iterator().next());

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public int countItems() {
 int count = 0;
 for (SlotKey slotKey : slots.values()) {
  count += slotKey.count;
 }
 return count;
}

代码示例来源:origin: com.google.code.findbugs/findbugs

/**
 * Get an iterator over the result facts.
 */
public Iterator<Fact> resultFactIterator() {
  return resultFactMap.values().iterator();
}

代码示例来源:origin: org.apache.felix/org.apache.felix.scr

private Collection<ComponentContextImpl<S>> getComponentContexts()
{
  synchronized ( serviceContexts )
  {
    return new ArrayList<>( serviceContexts.values() );
  }
}

代码示例来源:origin: owlcs/owlapi

/**
 * @return all values in the map
 */
public Set<V> getAllValues() {
  Set<V> toReturn = CollectionFactory.createSet();
  for (Collection<V> s : this.map.values()) {
    toReturn.addAll(s);
  }
  return toReturn;
}

相关文章