本文整理了Java中java.util.WeakHashMap.remove()
方法的一些代码示例,展示了WeakHashMap.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeakHashMap.remove()
方法的具体详情如下:
包路径:java.util.WeakHashMap
类名称:WeakHashMap
方法名:remove
[英]Removes the mapping with the specified key from this map.
[中]从此映射中删除具有指定键的映射。
代码示例来源:origin: android-hacker/VirtualXposed
public void removePackage(String packageName) {
synchronized (this) {
mPackages.remove(packageName);
}
}
代码示例来源:origin: robovm/robovm
@Override
public boolean remove(Object key) {
if (containsKey(key)) {
WeakHashMap.this.remove(key);
return true;
}
return false;
}
代码示例来源:origin: robovm/robovm
public static void clearCache(ClassLoader loader) {
if (loader == null) {
throw new NullPointerException("loader == null");
}
cache.remove(loader);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Removes the buffer for the current thread.
*/
private void removeBuffer() {
Thread current = Thread.currentThread();
buffers.remove(current);
}
代码示例来源:origin: robovm/robovm
public static void clearCache() {
cache.remove(ClassLoader.getSystemClassLoader());
}
代码示例来源:origin: apache/geode
@Override
public synchronized V remove(Object key) {
WeakHashMap<K, V> tmp = new WeakHashMap<K, V>(map);
V result = tmp.remove(key);
map = Collections.unmodifiableMap(tmp);
return result;
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
public void restore(Node node) {
CacheMemento cacheMemento = cache.remove(node);
if (cacheMemento != null) {
cacheMemento.restore();
}
}
};
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public void binderDied() {
token.unlinkToDeath(this, 0);
mProxyIIntentReceivers.remove(token);
}
}, 0);
代码示例来源:origin: mabe02/lanterna
private static synchronized void removeTaskFromTimer(AnimatedLabel animatedLabel) {
SCHEDULED_TASKS.get(animatedLabel).cancel();
SCHEDULED_TASKS.remove(animatedLabel);
canCloseTimer();
}
代码示例来源:origin: androidquery/androidquery
/**
* Dismiss a dialog previously shown with show().
*
* @return self
*
*/
public T dismiss(Dialog dialog){
try{
if(dialog != null){
dialogs.remove(dialog);
dialog.dismiss();
}
}catch(Exception e){
}
return self();
}
代码示例来源:origin: apache/geode
/**
* Throws LeaseExpiredException if the calling thread's lease on this lock previously expired. The
* expired lease will no longer be tracked after throwing LeaseExpiredException. Caller must
* synchronize on this lock token.
*
* @throws LeaseExpiredException if calling thread's lease expired
*/
void throwIfCurrentThreadHadExpiredLease() throws LeaseExpiredException {
if (this.expiredLeases == null) {
return;
}
if (this.expiredLeases.containsKey(Thread.currentThread())) {
this.expiredLeases.remove(Thread.currentThread());
throw new LeaseExpiredException(
"This thread's lease expired for this lock");
}
}
代码示例来源:origin: facebook/litho
public static void onContextDestroyed(Context context) {
if (mTrackedContexts == null) {
throw new RuntimeException(
"onContextDestroyed called without onContextCreated for: " + context);
}
LeakDetector removed = mTrackedContexts.remove(context);
if (removed == null) {
throw new RuntimeException(
"onContextDestroyed called without onContextCreated for: " + context);
} else {
removed.clear();
}
ComponentsPools.onContextDestroyed(context);
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
public void restore(Pane node) {
ArrayList<Node> children = cache.remove(node);
if (children != null) {
node.getChildren().setAll(children);
}
}
};
代码示例来源:origin: naman14/Timber
public static void unbindFromService(final ServiceToken token) {
if (token == null) {
return;
}
final ContextWrapper mContextWrapper = token.mWrappedContext;
final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper);
if (mBinder == null) {
return;
}
mContextWrapper.unbindService(mBinder);
if (mConnectionMap.isEmpty()) {
mService = null;
}
}
代码示例来源:origin: aa112901/remusic
public static void unbindFromService(final ServiceToken token) {
if (token == null) {
return;
}
final ContextWrapper mContextWrapper = token.mWrappedContext;
final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper);
if (mBinder == null) {
return;
}
mContextWrapper.unbindService(mBinder);
if (mConnectionMap.isEmpty()) {
mService = null;
}
}
代码示例来源:origin: grandcentrix/tray
public void unregisterOnTrayPreferenceChangeListener(
@NonNull final OnTrayPreferenceChangeListener listener) {
// noinspection ConstantConditions
if (listener == null) {
return;
}
mListeners.remove(listener);
if (mListeners.size() == 0) {
mContext.getContentResolver().unregisterContentObserver(mObserver);
// cleanup
mObserver = null;
mObserverThread.quit();
mObserverThread = null;
}
}
代码示例来源:origin: fengjiachun/Jupiter
static AccessorClassLoader get(Class<?> type) {
ClassLoader parent = getParentClassLoader(type);
// 1. 最快路径:
if (selfContextParentClassLoader.equals(parent)) {
if (selfContextAccessorClassLoader == null) {
synchronized (accessorClassLoaders) { // DCL with volatile semantics
if (selfContextAccessorClassLoader == null)
selfContextAccessorClassLoader = new AccessorClassLoader(selfContextParentClassLoader);
}
}
return selfContextAccessorClassLoader;
}
// 2. 常规查找:
synchronized (accessorClassLoaders) {
WeakReference<AccessorClassLoader> ref = accessorClassLoaders.get(parent);
if (ref != null) {
AccessorClassLoader accessorClassLoader = ref.get();
if (accessorClassLoader != null) {
return accessorClassLoader;
} else {
accessorClassLoaders.remove(parent); // the value has been GC-reclaimed, but still not the key (defensive sanity)
}
}
AccessorClassLoader accessorClassLoader = new AccessorClassLoader(parent);
accessorClassLoaders.put(parent, new WeakReference<>(accessorClassLoader));
return accessorClassLoader;
}
}
代码示例来源:origin: fengjiachun/Jupiter
static AccessorClassLoader get(Class<?> type) {
ClassLoader parent = getParentClassLoader(type);
// 1. 最快路径:
if (selfContextParentClassLoader.equals(parent)) {
if (selfContextAccessorClassLoader == null) {
synchronized (accessorClassLoaders) { // DCL with volatile semantics
if (selfContextAccessorClassLoader == null)
selfContextAccessorClassLoader = new AccessorClassLoader(selfContextParentClassLoader);
}
}
return selfContextAccessorClassLoader;
}
// 2. 常规查找:
synchronized (accessorClassLoaders) {
WeakReference<AccessorClassLoader> ref = accessorClassLoaders.get(parent);
if (ref != null) {
AccessorClassLoader accessorClassLoader = ref.get();
if (accessorClassLoader != null) {
return accessorClassLoader;
} else {
accessorClassLoaders.remove(parent); // the value has been GC-reclaimed, but still not the key (defensive sanity)
}
}
AccessorClassLoader accessorClassLoader = new AccessorClassLoader(parent);
accessorClassLoaders.put(parent, new WeakReference<>(accessorClassLoader));
return accessorClassLoader;
}
}
代码示例来源:origin: yahoo/squidb
private void dispose(boolean finalized) {
final SQLiteConnectionPool pool;
synchronized (mLock) {
if (mCloseGuardLocked != null) {
if (finalized) {
mCloseGuardLocked.warnIfOpen();
}
mCloseGuardLocked.close();
}
pool = mConnectionPoolLocked;
mConnectionPoolLocked = null;
}
if (!finalized) {
synchronized (sActiveDatabases) {
sActiveDatabases.remove(this);
}
if (pool != null) {
pool.close();
}
}
}
代码示例来源:origin: yahoo/squidb
AcquiredConnectionStatus status = mAcquiredConnections.remove(connection);
if (status == null) {
throw new IllegalStateException("Cannot perform this operation "
内容来源于网络,如有侵权,请联系作者删除!