java.util.WeakHashMap.keySet()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(122)

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

WeakHashMap.keySet介绍

[英]Returns a set of the keys contained in this map. The set is backed by this map so changes to one are reflected by the other. The set does not support adding.
[中]返回此映射中包含的一组键。该集合由该地图支持,因此对其中一个的更改会反映在另一个地图上。集合不支持添加。

代码示例

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

/**
 * Reload existing configuration instances.
 */
public static synchronized void reloadExistingConfigurations() {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Reloading " + REGISTRY.keySet().size()
        + " existing configurations");
  }
  for (Configuration conf : REGISTRY.keySet()) {
    conf.reloadConfiguration();
  }
}

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

/**
 * @return all threads that have active contexts
 */
public static Set<Thread> activeThreads()
{
  synchronized (contextStacksMap)
  {
    return new HashSet<>(contextStacksMap.keySet());
  }
}

代码示例来源:origin: yahoo/squidb

private static ArrayList<SQLiteDatabase> getActiveDatabases() {
  ArrayList<SQLiteDatabase> databases = new ArrayList<SQLiteDatabase>();
  synchronized (sActiveDatabases) {
    databases.addAll(sActiveDatabases.keySet());
  }
  return databases;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Reload existing configuration instances.
 */
public static synchronized void reloadExistingConfigurations() {
 if (LOG.isDebugEnabled()) {
  LOG.debug("Reloading " + REGISTRY.keySet().size()
    + " existing configurations");
 }
 for (Configuration conf : REGISTRY.keySet()) {
  conf.reloadConfiguration();
 }
}

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

public synchronized void clearTimers()
{
  if (timers != null)
  {
    timers.keySet().stream()
        .filter(r -> r != null)
        .forEach(Registration::dispose);
    timers.clear();
    timers = null;
  }
}

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

/**
 * Add a default resource. Resources are loaded in the order of the resources
 * added.
 * @param name file name. File should be present in the classpath.
 */
public static synchronized void addDefaultResource(String name) {
 if(!defaultResources.contains(name)) {
  defaultResources.add(name);
  for(Configuration conf : REGISTRY.keySet()) {
   if(conf.loadDefaults) {
    conf.reloadConfiguration();
   }
  }
 }
}

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

/**
 * Add a default resource. Resources are loaded in the order of the resources
 * added.
 * @param name file name. File should be present in the classpath.
 */
public static synchronized void addDefaultResource(String name) {
  if(!defaultResources.contains(name)) {
    defaultResources.add(name);
    for(Configuration conf : REGISTRY.keySet()) {
      if(conf.loadDefaults) {
        conf.reloadConfiguration();
      }
    }
  }
}

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

/**
 * Dismiss any AQuery dialogs.
 * 
 * @return self
 * 
 */
public T dismiss(){
  
  Iterator<Dialog> keys = dialogs.keySet().iterator();
  
  while(keys.hasNext()){
    
    Dialog d = keys.next();
    try{
      d.dismiss();
    }catch(Exception e){				
    }
    keys.remove();
    
  }
  return self();
  
}

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

@Override
public final void callback(String url, Bitmap bm, AjaxStatus status) {
  
  ImageView firstView = v.get();
  WeakHashMap<ImageView, BitmapAjaxCallback> ivs = queueMap.remove(url);
  
  //check if view queue already contains first view 
  if(ivs == null || !ivs.containsKey(firstView)){
    checkCb(this, url, firstView, bm, status);
  }
  
  if(ivs != null){
  
    Set<ImageView> set = ivs.keySet();
    
    for(ImageView view: set){
      BitmapAjaxCallback cb = ivs.get(view);
      cb.status = status;                
      checkCb(cb, url, view, bm, status);
    }
  
  }
  
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Add a default resource. Resources are loaded in the order of the resources 
 * added.
 * @param name file name. File should be present in the classpath.
 */
public static synchronized void addDefaultResource(String name) {
 if(!defaultResources.contains(name)) {
  defaultResources.add(name);
  for(Configuration conf : REGISTRY.keySet()) {
   if(conf.loadDefaults) {
    conf.reloadConfiguration();
   }
  }
 }
}

代码示例来源:origin: grandcentrix/tray

final Collection<OnTrayPreferenceChangeListener> listeners = mListeners.keySet();

代码示例来源:origin: yahoo/squidb

int idleConnections = 0;
if (!mAcquiredConnections.isEmpty()) {
  for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
    String description = connection.describeCurrentOperationUnsafe();
    if (description != null) {

代码示例来源:origin: commons-httpclient/commons-httpclient

ALL_CONNECTION_MANAGERS.keySet().toArray(
  new MultiThreadedHttpConnectionManager
    [ALL_CONNECTION_MANAGERS.size()]

代码示例来源:origin: yahoo/squidb

/**
 * Collects statistics about database connection memory usage.
 *
 * @param dbStatsList The list to populate.
 */
public void collectDbStats(ArrayList<DbStats> dbStatsList) {
  synchronized (mLock) {
    if (mAvailablePrimaryConnection != null) {
      mAvailablePrimaryConnection.collectDbStats(dbStatsList);
    }
    for (SQLiteConnection connection : mAvailableNonPrimaryConnections) {
      connection.collectDbStats(dbStatsList);
    }
    for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
      connection.collectDbStatsUnsafe(dbStatsList);
    }
  }
}

代码示例来源:origin: yahoo/squidb

private SQLiteConnection tryAcquirePrimaryConnectionLocked(int connectionFlags) {
  // If the primary connection is available, acquire it now.
  SQLiteConnection connection = mAvailablePrimaryConnection;
  if (connection != null) {
    mAvailablePrimaryConnection = null;
    finishAcquireConnectionLocked(connection, connectionFlags); // might throw
    return connection;
  }
  // Make sure that the primary connection actually exists and has just been acquired.
  for (SQLiteConnection acquiredConnection : mAcquiredConnections.keySet()) {
    if (acquiredConnection.isPrimaryConnection()) {
      return null;
    }
  }
  // Uhoh.  No primary connection!  Either this is the first time we asked
  // for it, or maybe it leaked?
  connection = openConnectionLocked(mConfiguration,
      true /*primaryConnection*/); // might throw
  finishAcquireConnectionLocked(connection, connectionFlags); // might throw
  return connection;
}

代码示例来源:origin: multidots/android-app-common-tasks

public Iterator<Thread> iterator() {
    return mWeakCollection.keySet().iterator();
  }
}

代码示例来源:origin: multidots/android-app-common-tasks

public Iterator<Thread> iterator() {
    return mWeakCollection.keySet().iterator();
  }
}

代码示例来源:origin: yahoo/squidb

private static ArrayList<SQLiteDatabase> getActiveDatabases() {
  ArrayList<SQLiteDatabase> databases = new ArrayList<SQLiteDatabase>();
  synchronized (sActiveDatabases) {
    databases.addAll(sActiveDatabases.keySet());
  }
  return databases;
}

代码示例来源:origin: yahoo/squidb

/**
 * Collects statistics about database connection memory usage.
 *
 * @param dbStatsList The list to populate.
 */
public void collectDbStats(ArrayList<DbStats> dbStatsList) {
  synchronized (mLock) {
    if (mAvailablePrimaryConnection != null) {
      mAvailablePrimaryConnection.collectDbStats(dbStatsList);
    }
    for (SQLiteConnection connection : mAvailableNonPrimaryConnections) {
      connection.collectDbStats(dbStatsList);
    }
    for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
      connection.collectDbStatsUnsafe(dbStatsList);
    }
  }
}

代码示例来源:origin: yahoo/squidb

private SQLiteConnection tryAcquirePrimaryConnectionLocked(int connectionFlags) {
  // If the primary connection is available, acquire it now.
  SQLiteConnection connection = mAvailablePrimaryConnection;
  if (connection != null) {
    mAvailablePrimaryConnection = null;
    finishAcquireConnectionLocked(connection, connectionFlags); // might throw
    return connection;
  }
  // Make sure that the primary connection actually exists and has just been acquired.
  for (SQLiteConnection acquiredConnection : mAcquiredConnections.keySet()) {
    if (acquiredConnection.isPrimaryConnection()) {
      return null;
    }
  }
  // Uhoh.  No primary connection!  Either this is the first time we asked
  // for it, or maybe it leaked?
  connection = openConnectionLocked(mConfiguration,
      true /*primaryConnection*/); // might throw
  finishAcquireConnectionLocked(connection, connectionFlags); // might throw
  return connection;
}

相关文章