private static void dropColumnDefinitions(final Collection<String> droppedColumnNames, final List<ColumnMetaData> columnMetaDataList) { List<ColumnMetaData> droppedColumnMetaDataList = new LinkedList<>(); for (ColumnMetaData each : columnMetaDataList) { if (droppedColumnNames.contains(each.getColumnName())) { droppedColumnMetaDataList.add(each); } } columnMetaDataList.removeAll(droppedColumnMetaDataList); } }
private static void removeCompletedStateUpdatesFromMap( Map<String, List<StateUpdate>> currentStateUpdates, Map<String, List<StateUpdate>> completedStateUpdates, String key) { List<StateUpdate> completed = completedStateUpdates.get(key); List<StateUpdate> current = currentStateUpdates.remove(key); if (completed != null && current != null) { current.removeAll(completed); } if (current != null && !current.isEmpty()) { currentStateUpdates.put(key, current); } }
private void updateFileLists(List<String> activeFiles, List<String> archiveFiles) throws IOException { List<String> newlyArchived = new ArrayList<>(); for (String spath : activeFiles) { if (!fs.exists(new Path(spath))) { newlyArchived.add(spath); } } if (newlyArchived.size() > 0) { activeFiles.removeAll(newlyArchived); archiveFiles.addAll(newlyArchived); } LOG.debug(newlyArchived.size() + " files have been archived."); }
private void removeRunningIfMonitorExecution(final boolean monitorExecution, final List<Integer> shardingItems) { if (!monitorExecution) { return; } List<Integer> runningShardingItems = new ArrayList<>(shardingItems.size()); for (int each : shardingItems) { if (isRunning(each)) { runningShardingItems.add(each); } } shardingItems.removeAll(runningShardingItems); }
@NonNull List<View> configureEnteringExitingViews(@NonNull Transition transition, @Nullable View view, @NonNull List<View> sharedElements, @NonNull View nonExistentView) { List<View> viewList = new ArrayList<>(); if (view != null) { captureTransitioningViews(viewList, view); } viewList.removeAll(sharedElements); if (!viewList.isEmpty()) { viewList.add(nonExistentView); TransitionUtils.addTargets(transition, viewList); } return viewList; }
private static void removeSpuriousMentionsZhSimple(Annotation doc, List<List<Mention>> predictedMentions, Dictionaries dict) { for(int i=0 ; i < predictedMentions.size() ; i++) { List<Mention> mentions = predictedMentions.get(i); Set<Mention> remove = Generics.newHashSet(); for(Mention m : mentions){ if (m.originalSpan.size()==1 && m.headWord.tag().equals("CD")) { remove.add(m); } if (m.spanToString().contains("quot")) { remove.add(m); } } mentions.removeAll(remove); } }
private List<ResourceWorkerSlot> getDifferNodeTaskWokers(String name) { List<ResourceWorkerSlot> workers = new ArrayList<>(); workers.addAll(taskContext.getWorkerToTaskNum().keySet()); for (Entry<String, List<ResourceWorkerSlot>> entry : taskContext.getSupervisorToWorker().entrySet()) { if (taskContext.getComponentNumOnSupervisor(entry.getKey(), name) != 0) workers.removeAll(entry.getValue()); } if (workers.size() == 0) { throw new FailedAssignTopologyException("there's no enough supervisor for making component: " + name + " 's tasks on different node"); } return workers; } }
private void removeBins(final String key, final List<RecordBin> bins) { lock.lock(); try { final List<RecordBin> list = groupBinMap.get(key); if (list != null) { final int initialSize = list.size(); list.removeAll(bins); // Determine how many items were removed from the list and // update our binCount to keep track of this. final int removedCount = initialSize - list.size(); binCount.addAndGet(-removedCount); if (list.isEmpty()) { groupBinMap.remove(key); } } } finally { lock.unlock(); } } }
protected void verifyUnmodifiable(List list) { try { list.add(0, new Integer(0)); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { list.add(new Integer(0)); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { list.addAll(0, array); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { list.addAll(array); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { list.clear(); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) { list.removeAll(array); fail("Expecting UnsupportedOperationException."); } catch (UnsupportedOperationException e) {
protected void suspect(Set<Address> suspects) { if(suspects == null) return; suspects.remove(local_addr); suspects.forEach(suspect -> suspect_history.add(String.format("%s: %s", new Date(), suspect))); suspected_mbrs.addAll(suspects); List<Address> eligible_mbrs=new ArrayList<>(this.members); eligible_mbrs.removeAll(suspected_mbrs); // Check if we're coord, then send up the stack if(local_addr != null && !eligible_mbrs.isEmpty() && local_addr.equals(eligible_mbrs.get(0))) { log.debug("%s: suspecting %s", local_addr, suspected_mbrs); up_prot.up(new Event(Event.SUSPECT, suspected_mbrs)); down_prot.down(new Event(Event.SUSPECT, suspected_mbrs)); } }
public List<T> mutate() { if (!canMutate()) { throw new IllegalStateException("No more mutations possible."); } if (removedIndex >= 0) { // last mutation was successful => clear the blacklist indexBlacklist.clear(); } int blockSize = Math.max(list.size() / blockPortion, 1); if (indexBlacklist.size() == list.size() / blockSize && list.size() / blockPortion > 1) { // we've tried all blocks without success => try smaller blocks and clear the blacklist blockPortion *= 2; indexBlacklist.clear(); } blockSize = Math.max(list.size() / blockPortion, 1); do { removedIndex = random.nextInt(list.size() / blockSize) * blockSize; } while (indexBlacklist.contains(removedIndex)); removedBlock = new ArrayList<>(list.subList(removedIndex, removedIndex + blockSize)); list.removeAll(removedBlock); return list; }
public void handleView(View view) { super.handleView(view); Address old_coord=coord; if(view.size() > 0) { coord=view.getCoord(); is_coord=coord.equals(local_addr); log.debug("[%s] coord=%s, is_coord=%b", local_addr, coord, is_coord); } if(is_coord && num_backups > 0) { List<Address> new_backups=Util.pickNext(view.getMembers(), local_addr, num_backups); List<Address> copy_locks_list=null; synchronized(backups) { if(!backups.equals(new_backups)) { copy_locks_list=new ArrayList<>(new_backups); copy_locks_list.removeAll(backups); backups.clear(); backups.addAll(new_backups); } } if(copy_locks_list != null && !copy_locks_list.isEmpty()) copyLocksTo(copy_locks_list); } // For all non-acquired client locks, send the GRANT_LOCK request to the new coordinator (if changed) if(old_coord != null && !old_coord.equals(coord)) client_lock_table.resendPendingLockRequests(); }
/** * Computes pingable_mbrs (based on the current membership and the suspected members) and ping_dest * @param remove The member to be removed from pingable_mbrs */ @GuardedBy("lock") protected void computePingDest(Address remove) { if(remove != null) pingable_mbrs.remove(remove); else { pingable_mbrs.clear(); pingable_mbrs.addAll(members); pingable_mbrs.removeAll(bcast_task.getSuspectedMembers()); } Address old_ping_dest=ping_dest; ping_dest=getPingDest(pingable_mbrs); if(Util.different(old_ping_dest, ping_dest)) { num_tries.set(1); last_ack=System.nanoTime(); } }
/** * 进行下拉刷新数据添加 并且刷新UI * @param pInstanceBeans */ public void addRefreshBeans(List<InstanceBean> pInstanceBeans){ List<InstanceBean> temp=new ArrayList<InstanceBean>(); temp.addAll(pInstanceBeans); temp.addAll(mInstanceBeans); mInstanceBeans.removeAll(mInstanceBeans); mInstanceBeans.addAll(temp); notifyDataSetChanged(); }
public static void sortContacts(List<Friend> list) { Collections.sort(list);//排序后由于#号排在上面,故得把#号的部分集合移动到集合的最下面 List<Friend> specialList = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { //将属于#号的集合分离开来 if (list.get(i).getNameSpelling().equalsIgnoreCase("#")) { specialList.add(list.get(i)); } } if (specialList.size() != 0) { list.removeAll(specialList);//先移出掉顶部的#号部分 list.addAll(list.size(), specialList);//将#号的集合添加到集合底部 } }