Refine search
/** * Drops the entry for {@code key} if it exists and can be removed. Entries * actively being edited cannot be removed. * * @return true if an entry was removed. */ public synchronized boolean remove(String key) throws IOException { checkNotClosed(); validateKey(key); Entry entry = lruEntries.get(key); if (entry == null || entry.currentEditor != null) { return false; } for (int i = 0; i < valueCount; i++) { File file = entry.getCleanFile(i); if (file.exists() && !file.delete()) { throw new IOException("failed to delete " + file); } size -= entry.lengths[i]; fileCount--; entry.lengths[i] = 0; } redundantOpCount++; journalWriter.append(REMOVE + ' ' + key + '\n'); lruEntries.remove(key); if (journalRebuildRequired()) { executorService.submit(cleanupCallable); } return true; }
/** * Adds an extra field - replacing an already present extra field * of the same type. * * <p>The new extra field will be the first one.</p> * @param ze an extra field * @since 1.1 */ public void addAsFirstExtraField(ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { LinkedHashMap<ZipShort, ZipExtraField> copy = extraFields; extraFields = new LinkedHashMap<ZipShort, ZipExtraField>(); extraFields.put(ze.getHeaderId(), ze); if (copy != null) { copy.remove(ze.getHeaderId()); extraFields.putAll(copy); } } setExtra(); }
@Override protected void writeContext(ObjectOutput output, LinkedHashMap<Object, Object> map) throws IOException { Object insertOrder = new Object(); Object accessOrder = new Object(); map.put(insertOrder, null); map.put(accessOrder, null); // Access first inserted entry // If map uses access order, this element will move to the tail of the map map.get(insertOrder); Iterator<Object> keys = map.keySet().iterator(); Object element = keys.next(); while ((element != insertOrder) && (element != accessOrder)) { element = keys.next(); } map.remove(insertOrder); map.remove(accessOrder); // Map uses access order if previous access changed iteration order output.writeBoolean(element == accessOrder); }
@Override @Nullable public V put(String key, @Nullable V value) { String oldKey = this.caseInsensitiveKeys.put(convertKey(key), key); V oldKeyValue = null; if (oldKey != null && !oldKey.equals(key)) { oldKeyValue = this.targetMap.remove(oldKey); } V oldValue = this.targetMap.put(key, value); return (oldKeyValue != null ? oldKeyValue : oldValue); }
/** * Drops the entry for {@code key} if it exists and can be removed. Entries * actively being edited cannot be removed. * * @return true if an entry was removed. */ public synchronized boolean remove(String key) throws IOException { checkNotClosed(); validateKey(key); Entry entry = lruEntries.get(key); if (entry == null || entry.currentEditor != null) { return false; } for (int i = 0; i < valueCount; i++) { File file = entry.getCleanFile(i); if (file.exists() && !file.delete()) { throw new IOException("failed to delete " + file); } size -= entry.lengths[i]; entry.lengths[i] = 0; } redundantOpCount++; journalWriter.append(REMOVE + ' ' + key + '\n'); lruEntries.remove(key); if (journalRebuildRequired()) { executorService.submit(cleanupCallable); } return true; }
aliasName = service_alias.substring(i + 1); if (propertyAliasTable != null) { propertyAliasTable.remove(key(serviceName, aliasName)); algorithm = k.substring(j + 1); if (propertyServiceTable != null) { Provider.Service ser = propertyServiceTable.remove(key(serviceName, algorithm)); if (ser != null && propertyAliasTable != null && ser.aliases != null) { for (String alias : ser.aliases) { propertyAliasTable.remove(key(serviceName, alias)); algorithm = k.substring(j + 1, i); if (propertyServiceTable != null) { Object o = propertyServiceTable.get(key(serviceName, algorithm)); if (o != null) { s = (Provider.Service) o;
TopicPartition topicPartition = entry.getKey(); PartitionData prevData = entry.getValue(); PartitionData nextData = next.get(topicPartition); if (nextData != null) { if (prevData.equals(nextData)) { next.remove(topicPartition); } else { next.remove(topicPartition); next.put(topicPartition, nextData); entry.setValue(nextData); altered.add(topicPartition); sessionPartitions.put(topicPartition, nextData); added.add(topicPartition);