/** * @deprecated Use {@link #unregister(long)} instead. */ @Deprecated public synchronized void unregister(T removed) { nativeObjToIdMap.inverse().remove(removed); }
@Override public ResourceUrn getUri(UIScreenLayer screen) { BiMap<ResourceUrn, UIScreenLayer> lookup = HashBiMap.create(screenLookup); return lookup.inverse().remove(screen); } @Override
private void closeScreen(ResourceUrn screenUri, boolean sendEvents) { UIScreenLayer screen = screenLookup.remove(screenUri); if (screen != null) { screens.remove(screen); onCloseScreen(screen, screenUri, sendEvents); } }
@Override public void closeScreen(UIScreenLayer screen) { if (screens.remove(screen)) { ResourceUrn screenUri = screenLookup.inverse().remove(screen); onCloseScreen(screen, screenUri, true); } }
public Object removeOriginalIdentifier(Object copy) { if (currentEquivalentMap.containsKey(System.identityHashCode(copy))) { currentCloneMap.remove(System.identityHashCode(copy)); String valKey = currentEquivalentMap.remove(System.identityHashCode(copy)); return Long.parseLong(valKey.substring(valKey.indexOf("_") + 1, valKey.length())); } return null; }
@Implementation(minSdk = KITKAT) @RequiresPermission(value = android.Manifest.permission.WATCH_APPOPS) protected void stopWatchingMode(OnOpChangedListener callback) { appOpListeners.inverse().remove(callback); }
@Override public synchronized <V> void registerClass(int registrationNo, Class<V> datatype, AttributeSerializer<V> serializer) { Preconditions.checkArgument(registrationNo >= 0 && registrationNo < MAX_REGISTRATION_NO, "Registration number" + " out of range [0,%s]: %s", MAX_REGISTRATION_NO, registrationNo); if (datatype == HashMap.class) { final Integer hashMapRegNo = registrations.inverse().get(normalizeDataType(HashMap.class)); if (hashMapRegNo != null) { // Remove the default HashMap serializer so we can replace it with the custom one registrations.remove(hashMapRegNo); handlers.remove(datatype); } } registerClassInternal(CLASS_REGISTRATION_OFFSET + registrationNo, datatype, serializer); }
void unregisterContainer(ContainerId containerId) { LlapNodeId llapNodeId = containerToNodeMap.remove(containerId); if (llapNodeId == null) { // Possible since either container / task can be unregistered. return; } BiMap<ContainerId, TezTaskAttemptID> bMap = nodeMap.get(llapNodeId); TezTaskAttemptID matched = null; if (bMap != null) { synchronized(bMap) { matched = bMap.remove(containerId); } if (bMap.isEmpty()) { nodeMap.remove(llapNodeId); } } // Remove the container mapping if (matched != null) { attemptToNodeMap.remove(matched); uniqueNodeMap.remove(matched); } }
void unregisterTaskAttempt(TezTaskAttemptID attemptId) { uniqueNodeMap.remove(attemptId); LlapNodeId llapNodeId; synchronized (attemptToNodeMap) { llapNodeId = attemptToNodeMap.remove(attemptId); if (llapNodeId == null) { // Possible since either container / task can be unregistered. return; } } BiMap<ContainerId, TezTaskAttemptID> bMap = nodeMap.get(llapNodeId); ContainerId matched = null; if (bMap != null) { synchronized(bMap) { matched = bMap.inverse().remove(attemptId); } if (bMap.isEmpty()) { nodeMap.remove(llapNodeId); } } // Remove the container mapping if (matched != null) { containerToNodeMap.remove(matched); } }
/** * Unregister an object previously registered with {@link #register(Object)}. * * @param nativeId the unique id (representing a C memory pointer) of the object to unregister. * @throws IllegalStateException if the object was never registered, or was previously * unregistered. */ public synchronized void unregister(long nativeId) { T o = nativeObjToIdMap.remove(nativeId); if (debug) { System.out.printf("NativeObjRegistry %s: unregister %d -> %s%n", name, nativeId, o); new RuntimeException("unregister debug").printStackTrace(System.out); } if (o == null) { if (debug) { DebugInfo debugInfo = idToDebugInfoMap.get(nativeId); debugInfo.unregistrationTraces.add(new Trace(o)); if (debugInfo.unregistrationTraces.size() > 1) { System.out.format("NativeObjRegistry %s: Too many unregistrations:%n", name); for (Trace unregistration : debugInfo.unregistrationTraces) { unregistration.printStackTrace(System.out); } } } throw new IllegalStateException( nativeId + " has already been removed (or was never registered)"); } }
public void testInsertionOrderAfterRemoveMiddle() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.remove("bar"); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("foo", 1), Maps.immutableEntry("quux", 3)) .inOrder(); }
public void testInsertionOrderAfterRemoveLast() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.remove("quux"); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("foo", 1), Maps.immutableEntry("bar", 2)) .inOrder(); }
public void testInsertionOrderAfterRemoveFirst() { BiMap<String, Integer> map = HashBiMap.create(); map.put("foo", 1); map.put("bar", 2); map.put("quux", 3); map.remove("foo"); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("bar", 2), Maps.immutableEntry("quux", 3)) .inOrder(); }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveFromInverseRemovesFromForward() { getMap().inverse().remove(v0()); expectMissing(e0()); }
private V putInBothMaps(@Nullable K key, @Nullable V value, boolean force) { checkKey(key); checkValue(value); boolean containedKey = containsKey(key); if (containedKey && Objects.equal(value, get(key))) { return value; } if (force) { inverse().remove(value); } else { checkArgument(!containsValue(value), "value already present: %s", value); } V oldValue = delegate.put(key, value); updateInverseMap(key, containedKey, oldValue, value); return oldValue; }
@SuppressWarnings("unchecked") @MapFeature.Require(SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemoveKeyRemovesFromInverse() { getMap().remove(k0()); expectMissing(e0()); }
private V putInBothMaps(@NullableDecl K key, @NullableDecl V value, boolean force) { checkKey(key); checkValue(value); boolean containedKey = containsKey(key); if (containedKey && Objects.equal(value, get(key))) { return value; } if (force) { inverse().remove(value); } else { checkArgument(!containsValue(value), "value already present: %s", value); } V oldValue = delegate.put(key, value); updateInverseMap(key, containedKey, oldValue, value); return oldValue; }
private V putInBothMaps(@NullableDecl K key, @NullableDecl V value, boolean force) { checkKey(key); checkValue(value); boolean containedKey = containsKey(key); if (containedKey && Objects.equal(value, get(key))) { return value; } if (force) { inverse().remove(value); } else { checkArgument(!containsValue(value), "value already present: %s", value); } V oldValue = delegate.put(key, value); updateInverseMap(key, containedKey, oldValue, value); return oldValue; }
public void unregister(long endPointId) { EndPoint endPoint = endPoints.get(endPointId); if (endPoint != null) { endPoints.remove(endPointId); endPoint.cleanup(); } }
public void unregister(EndPoint endPoint) { endPoints.remove(endPoint.getEndPointId()); tokenToEndPoint.remove(endPoint.getToken()); endPoint.cleanup(); }