Java Code Examples for java.util.List.remove()

The following are Jave code examples for showing how to use remove() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: karate   File: Script.java   Source Code and License Vote up 8 votes
public static String replacePlaceholders(String text, List<Map<String, String>> list, ScriptContext context) {
    if (text == null) {
        return null;
    }
    if (list == null) {
        return text;
    }
    for (Map<String, String> map : list) {
        String token = map.get(TOKEN);
        if (token == null) {
            continue;
        }
        // the verbosity below is to be lenient with table second column name
        List<String> keys = new ArrayList(map.keySet());
        keys.remove(TOKEN);
        Iterator<String> iterator = keys.iterator();
        if (iterator.hasNext()) {
            String key = keys.iterator().next();
            String value = map.get(key);
            text = replacePlaceholderText(text, token, value, context);
        }
    }
    return text;
}
 
Example 2
Project: azure-libraries-for-java   File: VirtualMachineScaleSetImpl.java   Source Code and License Vote up 7 votes
private void removeDataDisks() {
    VirtualMachineScaleSetStorageProfile storageProfile = this.vmss
            .inner()
            .virtualMachineProfile()
            .storageProfile();
    List<VirtualMachineScaleSetDataDisk> dataDisks = storageProfile.dataDisks();
    for (Integer lun : this.diskLunsToRemove) {
        int indexToRemove = 0;
        for (VirtualMachineScaleSetDataDisk dataDisk : dataDisks) {
            if (dataDisk.lun() == lun) {
                dataDisks.remove(indexToRemove);
                break;
            }
            indexToRemove++;
        }
    }
}
 
Example 3
Project: Backmemed   File: HttpPipelineConnection.java   Source Code and License Vote up 7 votes
private HttpPipelineRequest getNextRequest(List<HttpPipelineRequest> p_getNextRequest_1_, boolean p_getNextRequest_2_) throws InterruptedException
{
    while (p_getNextRequest_1_.size() <= 0)
    {
        this.checkTimeout();
        this.wait(1000L);
    }

    this.onActivity();

    if (p_getNextRequest_2_)
    {
        return (HttpPipelineRequest)p_getNextRequest_1_.remove(0);
    }
    else
    {
        return (HttpPipelineRequest)p_getNextRequest_1_.get(0);
    }
}
 
Example 4
Project: syndesis-qe   File: IntegrationSteps.java   Source Code and License Vote up 7 votes
@Then("^she delete step on position \"(\\d+)\" and check rest$")
public void deleteStepOnPositionAndCheckRest(Integer positionOfStep) {
	log.info("Deleting step on position {}", positionOfStep);
	List<String> list = editPage.getFlowViewComponent().getStepsArray();
	ElementsCollection deletes = this.editPage.getFlowViewComponent().getAllTrashes().shouldBe(sizeGreaterThanOrEqual(1));
	Integer indexOfStep = positionOfStep + 1;
	deletes.get(indexOfStep).click();
	editPage.clickOnFirstVisibleButton("OK");
	list.remove(positionOfStep);
	//NOW CHECK:
	List<String> list2 = editPage.getFlowViewComponent().getStepsArray();
	for (int i = 0; i < list.size(); i++) {
		log.info("assserting {} and {}", list.get(i), list2.get(i));
		assertThat(list.get(i), is(list2.get(i)));
	}
}
 
Example 5
Project: Android-Scrapper   File: LeagueBase.java   Source Code and License Vote up 6 votes
@Override
    public List<Game> pullGamesFromNetwork(Context context) throws IOException, ExpectedElementNotFound {
        this.context = context;
        if (context != null) {
            Log.e(TAG, "Started " + getAcronym() + " " + getScoreType());
        }
        List<Game> updatedGameList = new LinkedList<>();
        Document parsedDocument = Jsoup.connect(getBaseUrl()).timeout(60 * 1000).get();
        updatedGameList = scrapeUpdateGamesFromParsedDocument(updatedGameList, parsedDocument);
        if (context != null) {
            storeDocument(parsedDocument);
            // Only add dates that are scheduled for that date.
            List<Game> tempList = new LinkedList<>(updatedGameList);
            for (Game game : tempList) {
                if (game.getGameAddDate() != new DateTime(Constants.DATE.VEGAS_TIME_ZONE).withTimeAtStartOfDay().getMillis()
//                        || new DateTime(game.getGameDateTime(), Constants.DATE.VEGAS_TIME_ZONE).toDateTime(DateTimeZone.getDefault()).isBeforeNow()
                        ) {
                    updatedGameList.remove(game);
                }
            }
            // Initiate teams for this league if not initiated
            syncDateWithEspn(updatedGameList);
        }
        updateLibraryInDatabase(updatedGameList, context);
        return updatedGameList;
    }
 
Example 6
Project: googles-monorepo-demo   File: ListMultimapRemoveTester.java   Source Code and License Vote up 6 votes
@SuppressWarnings("unchecked")
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testRemoveAtIndexFromGetPropagates() {
  List<V> values = Arrays.asList(v0(), v1(), v0());

  for (int i = 0; i < 3; i++) {
    resetContainer(mapEntry(k0(), v0()), mapEntry(k0(), v1()), mapEntry(k0(), v0()));
    List<V> expectedValues = copyToList(values);

    multimap().get(k0()).remove(i);
    expectedValues.remove(i);

    assertGet(k0(), expectedValues);
  }
}
 
Example 7
Project: ats-framework   File: Test_MetaData.java   Source Code and License Vote up 5 votes
private boolean compareMixedLists( List<String> expected, List<String> actual ) {

        for (String name : expected) {
            for (int i = 0; i < actual.size(); i++) {
                if (actual.get(i).trim().equals(name.trim())) {
                    actual.remove(i);
                    break;
                } else if (i == actual.size() - 1) {
                    return false;
                }
            }
        }
        return actual.isEmpty();
    }
 
Example 8
Project: RollenspielAlexaSkill   File: SoloRoleplayGame.java   Source Code and License Vote up 5 votes
public PersistentDataSoloRoleplayGame getPersistentData() {
	PersistentDataSoloRoleplayGame result = new PersistentDataSoloRoleplayGame();
	result.setChapter(lastChapter);
	result.setStep(lastStep);
	result.setReturnChapter(returnChapter);
	result.setReturnStep(returnStep);
	List<String> historyCopy = new ArrayList<String>(history);
	while(historyCopy.size() > lastHistorySize) {
		historyCopy.remove(historyCopy.size()-1);
	}
	result.setHistory(historyCopy);
	return result; 
}
 
Example 9
Project: elements-of-programming-interviews-solutions   File: ComputeRandomSubsetTest.java   Source Code and License Vote up 5 votes
private void test(int n, int k) {
    final List<Integer> sequence = StreamUtil.sequence(n);
    final List<Integer> subset = ComputeRandomSubset.randomSubset(n, k);
    assertNotEquals(sequence, subset);
    assertEquals(k, subset.size());
    for (Integer i : subset) {
        assertTrue(sequence.contains(i));
        sequence.remove(i);
    }
}
 
Example 10
Project: VanillaPlus   File: CPOther.java   Source Code and License Vote up 5 votes
@Override
public List<String> onTab(VPSender sender, String label, List<String> args) {
	if ( args == null ) args = new ArrayList<>();
	List<String>result = new ArrayList<>();
	if (!otherAtEnd && args.size() < 2 && otherRequirement.has(sender) ) {
		result.addAll(VanillaPlusCore.getPlayerManager().getPlayersList(args.isEmpty() ? "" : args.get(0), online));
		result.remove(sender.getName());
	}
	return result;
}
 
Example 11
Project: BiglyBT   File: SystemTime.java   Source Code and License Vote up 5 votes
public static void unregisterMonotonousConsumer(TickConsumer c) {
	synchronized (instance)
	{
		List new_list = new ArrayList(monotoneTimeConsumers);
		new_list.remove(c);
		monotoneTimeConsumers = new_list;
	}
}
 
Example 12
Project: jdk8u-jdk   File: FileUtils.java   Source Code and License Vote up 5 votes
/**
 * Deletes a directory and its subdirectories, retrying if necessary.
 *
 * @param dir  the directory to delete
 *
 * @throws  IOException
 *          If an I/O error occurs. Any such exceptions are caught
 *          internally. If only one is caught, then it is re-thrown.
 *          If more than one exception is caught, then the second and
 *          following exceptions are added as suppressed exceptions of the
 *          first one caught, which is then re-thrown.
 */
public static void deleteFileTreeWithRetry(Path dir)
     throws IOException
{
    IOException ioe = null;
    final List<IOException> excs = deleteFileTreeUnchecked(dir);
    if (!excs.isEmpty()) {
        ioe = excs.remove(0);
        for (IOException x : excs)
            ioe.addSuppressed(x);
    }
    if (ioe != null)
        throw ioe;
}
 
Example 13
Project: Xndroid   File: HorizontalItemAnimator.java   Source Code and License Vote up 5 votes
private void endChangeAnimation(List<ChangeInfo> infoList, ViewHolder item) {
    for (int i = infoList.size() - 1; i >= 0; i--) {
        ChangeInfo changeInfo = infoList.get(i);
        if (endChangeAnimationIfNecessary(changeInfo, item)) {
            if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
                infoList.remove(changeInfo);
            }
        }
    }
}
 
Example 14
Project: BeamTeamDiscordBot   File: FollowReport.java   Source Code and License Vote up 4 votes
@Override
protected void execute(CommandEvent event) {
	if (!StringUtils.isBlank(event.getArgs()) && event.getArgs().split(" ").length >= 2) {
		String teamArg = event.getArgs().split(" ")[0];
		List<String> userArgs = new ArrayList<String>(Arrays.asList(event.getArgs().split(" ")));
		userArgs.remove(0);

		BeamTeam team = CommandHelper.getTeam(event, teamArg);

		if (null != team) {
			List<BeamTeamUser> teamMembers = BeamManager.getTeamMembers(team);

			for (String userArg : userArgs) {
				StringBuilder followingList = new StringBuilder();
				StringBuilder notFollowingList = new StringBuilder();
				int followingCount = 0, notFollowingCount = 0;

				BTBBeamUser user = BeamManager.getUser(userArg);

				List<BTBBeamChannel> userFollows = BeamManager.getFollowing(user);

				for (BeamTeamUser member : teamMembers) {
					if (!member.equals(user)) {
						boolean isNotFollowingMember = true;

						for (BTBBeamChannel followee : userFollows) {
							if (member.channel.id == followee.id) {
								followingList.append(String.format("[%s](https://beam.pro/%s)\n", member.username,
										member.username));
								isNotFollowingMember = false;
								++followingCount;
								break;
							} else if (member.channel.id < followee.id) {
								break;
							}
						}

						if (isNotFollowingMember) {
							notFollowingList.append(
									String.format("[%s](https://beam.pro/%s)\n", member.username, member.username));
							++notFollowingCount;
						}
					}
				}

				if (followingCount == 0) {
					followingList.append("NONE");
				}

				if (notFollowingCount == 0) {
					notFollowingList.append("NONE");
				}

				CommandHelper.sendPaginationDM(event, followingList.toString().split("\n"), 1,
						"%s is Following %d/%d %s Members", user.username, followingCount, teamMembers.size(),
						team.name);

				CommandHelper.sendPaginationDM(event, notFollowingList.toString().split("\n"), 1,
						"%s is Not Following %d/%d %s Members", user.username, notFollowingCount,
						teamMembers.size(), team.name);
			}
		}
	} else {
		JDAManager.sendMessage(event, "Missing arguments from command!");
	}
}
 
Example 15
Project: incubator-netbeans   File: MagicSurroundWithTryCatchFix.java   Source Code and License Vote up 4 votes
public @Override Void visitTry(TryTree tt, Void p) {
    List<CatchTree> catches = new ArrayList<CatchTree>();
            
    catches.addAll(tt.getCatches());
    catches.addAll(createCatches(info, make, thandles, statement));
    
    if (!streamAlike) {
        info.rewrite(tt, make.Try(tt.getResources(), tt.getBlock(), catches, tt.getFinallyBlock()));
    } else {
        VariableTree originalDeclaration = (VariableTree) statement.getLeaf();
        VariableTree declaration = make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), originalDeclaration.getName(), originalDeclaration.getType(), make.Literal(null));
        StatementTree assignment = make.ExpressionStatement(make.Assignment(make.Identifier(originalDeclaration.getName()), originalDeclaration.getInitializer()));
        List<StatementTree> finallyStatements = new ArrayList<StatementTree>(tt.getFinallyBlock() != null ? tt.getFinallyBlock().getStatements() : Collections.<StatementTree>emptyList());
        
        finallyStatements.add(createFinallyCloseBlockStatement(originalDeclaration));
        
        BlockTree finallyTree = make.Block(finallyStatements, false);
        
        info.rewrite(originalDeclaration, assignment);
        
        TryTree nueTry = make.Try(tt.getResources(), tt.getBlock(), catches, finallyTree);
        
        TreePath currentBlockCandidate = statement;
        
        while (currentBlockCandidate.getLeaf() != tt) {
            currentBlockCandidate = currentBlockCandidate.getParentPath();
        }

        currentBlockCandidate = currentBlockCandidate.getParentPath();
        
        if (currentBlockCandidate.getLeaf().getKind() == Kind.BLOCK) {
            BlockTree originalTree = (BlockTree) currentBlockCandidate.getLeaf();
            List<StatementTree> statements = new ArrayList<StatementTree>(originalTree.getStatements());
            int index = statements.indexOf(tt);
            
            statements.remove(index);
            statements.add(index, nueTry);
            statements.add(index, declaration);
            info.rewrite(originalTree, make.Block(statements, originalTree.isStatic()));
        } else {
            BlockTree nueBlock = make.Block(Arrays.asList(declaration, nueTry), false);
            
            info.rewrite(tt, nueBlock);
        }
    }
    
    return null;
}
 
Example 16
Project: Core   File: ContextProcessorEngineImpl.java   Source Code and License Vote up 4 votes
public void unbindProcessor(ContextProcessor processor) {
    List<ContextProcessor> contextProcessorsSamePriority = this.contextProcessors.get(processor.priority());
    contextProcessorsSamePriority.remove(processor);
}
 
Example 17
Project: incubator-netbeans   File: MarkupAbstractIndenter.java   Source Code and License Vote up 4 votes
private List<MarkupItem> calculateAllVirtualCloseTagsForCloseTag(MarkupItem newItem) {
    // iterate backwards over existing state items and:
    // if tag is closing tag then jump before its opening tag and continue
    // if tag is open tag then:
    //   if it matches tag being closed then everything is OK - break;
    //   else if tag has optional close tag then CLOSE it with virtual tag and continue going backwards.
    //   else if tag does not match and is not mandatory: something wrong so nothing break;
    int lastFailureSize = -1;
    List<MarkupItem> newItems = new ArrayList<MarkupItem>();
    for (int i=getStack().size()-1; i>=0; i--) {
        MarkupItem item = getStack().get(i);
        // found a closing tag -> jump before corresponding open tag
        if (!item.openingTag) {
            int index = indexOfOpenTag(getStack(), item, i);
            if (index != -1) {
                i = index;
            } else if (AbstractIndenter.DEBUG) {
                System.err.println("WARNING: cannot find open tag for "+item+" before index "+i+": "+(getStack().size() < 30 ? getStack() : "[too many items]"));
            }
            continue;
        } else {
            if (LexerUtils.equals(item.tagName, newItem.tagName, true, false)) {
                lastFailureSize = -1;
                // nothing to do:
                break;
            } else if (item.optionalClosingTag) {
                if (lastFailureSize == -1) {
                    lastFailureSize = newItems.size();
                }
                newItems.add(MarkupAbstractIndenter.createVirtualMarkupItem(item.tagName, item.empty));
            } else {
                if (lastFailureSize == -1) {
                    // recovery attempt: ignore this tag and keep looking backwards
                    lastFailureSize = newItems.size();
                    newItems.add(MarkupAbstractIndenter.createVirtualMarkupItem(item.tagName, item.empty));
                    continue;
                } else {
                    // recovery failed; rollback to where we were before recovery and exit
                    if (AbstractIndenter.DEBUG) {
                        System.err.println("WARNING: cannot find opening tag for "+newItem+": "+getStack()+" stopped searching at "+item);
                    }
                    // resuse eliminated attribute here to simply ignore newItem
                    newItem.eliminated = true;
                    break;
                }

            }
        }
    }
    if (lastFailureSize != -1) {
        while (newItems.size() > lastFailureSize) {
            newItems.remove(newItems.size()-1);
        }
    }
    return newItems;
}
 
Example 18
Project: boohee_v5.6   File: ActivityChooserModel.java   Source Code and License Vote up 4 votes
public Void doInBackground(Object... args) {
    List<HistoricalRecord> historicalRecords = args[0];
    String hostoryFileName = args[1];
    try {
        FileOutputStream fos = ActivityChooserModel.this.mContext.openFileOutput(hostoryFileName, 0);
        XmlSerializer serializer = Xml.newSerializer();
        try {
            serializer.setOutput(fos, null);
            serializer.startDocument("UTF-8", Boolean.valueOf(true));
            serializer.startTag(null, ActivityChooserModel.TAG_HISTORICAL_RECORDS);
            int recordCount = historicalRecords.size();
            for (int i = 0; i < recordCount; i++) {
                HistoricalRecord record = (HistoricalRecord) historicalRecords.remove(0);
                serializer.startTag(null, ActivityChooserModel.TAG_HISTORICAL_RECORD);
                serializer.attribute(null, "activity", record.activity.flattenToString());
                serializer.attribute(null, ActivityChooserModel.ATTRIBUTE_TIME, String.valueOf(record.time));
                serializer.attribute(null, "weight", String.valueOf(record.weight));
                serializer.endTag(null, ActivityChooserModel.TAG_HISTORICAL_RECORD);
            }
            serializer.endTag(null, ActivityChooserModel.TAG_HISTORICAL_RECORDS);
            serializer.endDocument();
            ActivityChooserModel.this.mCanReadHistoricalData = true;
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                }
            }
        } catch (IllegalArgumentException iae) {
            Log.e(ActivityChooserModel.LOG_TAG, "Error writing historical recrod file: " + ActivityChooserModel.this.mHistoryFileName, iae);
            ActivityChooserModel.this.mCanReadHistoricalData = true;
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e2) {
                }
            }
        } catch (IllegalStateException ise) {
            Log.e(ActivityChooserModel.LOG_TAG, "Error writing historical recrod file: " + ActivityChooserModel.this.mHistoryFileName, ise);
            ActivityChooserModel.this.mCanReadHistoricalData = true;
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e3) {
                }
            }
        } catch (IOException ioe) {
            Log.e(ActivityChooserModel.LOG_TAG, "Error writing historical recrod file: " + ActivityChooserModel.this.mHistoryFileName, ioe);
            ActivityChooserModel.this.mCanReadHistoricalData = true;
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e4) {
                }
            }
        } catch (Throwable th) {
            ActivityChooserModel.this.mCanReadHistoricalData = true;
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e5) {
                }
            }
        }
        return null;
    } catch (FileNotFoundException fnfe) {
        Log.e(ActivityChooserModel.LOG_TAG, "Error writing historical recrod file: " + hostoryFileName, fnfe);
        return null;
    }
}
 
Example 19
Project: MaxSim   File: InputSlot.java   Source Code and License Vote up 4 votes
@Override
public void setPosition(int position) {
    List<InputSlot> inputSlots = getFigure().inputSlots;
    InputSlot s = inputSlots.remove(position);
    inputSlots.add(position, s);
}
 
Example 20
Project: esup-ecandidat   File: OffreFormationController.java   Source Code and License Vote up 4 votes
/** Supprime un centre de candidature de l'offre
 * @param ctrCand
 */
private void removeInternalCtrCand(CentreCandidature ctrCand, List<OdfCtrCand> offreDeFormation){
	offreDeFormation.remove(new OdfCtrCand(ctrCand.getIdCtrCand(),ctrCand.getLibCtrCand()));		
}