List of usage examples for java.util List remove
E remove(int index);
From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.DDLFormRuleToDDMFormRuleConverter.java
protected String createCondition(String functionName, List<DDLFormRuleCondition.Operand> operands) { if (Objects.equals(functionName, "belongsTo")) { operands.remove(0); }/*from ww w .ja v a 2s . c o m*/ return String.format(_functionCallUnaryExpressionFormat, functionName, convertOperands(operands)); }
From source file:edu.mayo.cts2.framework.plugin.service.umls.domain.codesystem.CodeSystemRepository.java
public DirectoryResult<CodeSystemCatalogEntrySummary> searchCodeSystemDirectorySummaries( CodeSystemMapper.SearchObject searchObject, int start, int end) { List<RootSourceDTO> dto = this.codeSystemMapper.searchRootSourceDTOs(searchObject, start, end + 1); if (dto != null) { List<CodeSystemCatalogEntrySummary> dtos = codeSystemFactory.createCodeSystem(dto); boolean atEnd = !(dtos.size() == (end + 1) - start); if (!atEnd) { dtos.remove(dto.size() - 1); }//from w w w .ja v a2 s .c o m return new DirectoryResult<CodeSystemCatalogEntrySummary>(dtos, atEnd); } else { return null; } }
From source file:geva.Operator.Operations.ReplacementOperation.java
/** * Remove the size number of worst geva.Individuals * @param operand geva.Individuals that might be removed * @param size Number of individuals to remove **//*ww w .j av a2 s .c o m*/ private void removeIndividuals(List<Individual> operand, int size) { int cnt = 0; while (cnt < size) { cnt++; operand.remove(this.fitnessA[this.fitnessA.length - cnt].getIndividual()); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.accounts.manageproxies.ManageProxiesCreatePage.java
private Collection<String> figureNonSelfProfileUris(UserAccount proxyAccount) { List<String> myProfiles = new ArrayList<String>(profileUris); for (Individual self : selfEditingConfiguration.getAssociatedIndividuals(indDao, proxyAccount)) { myProfiles.remove(self.getURI()); }/*w w w . j a va2 s.c o m*/ return myProfiles; }
From source file:com.microsoft.alm.plugin.idea.common.starters.ApplicationStarterBase.java
@Override public void main(String[] args) { logger.debug("Args passed to VSTS to process: {}", Arrays.toString(args)); try {/*from ww w. j a v a 2 s . c om*/ if (StringUtils.startsWithIgnoreCase(args[1], URI_PREFIX)) { // pass the uri but after removing it's prefix since it isn't needed anymore processUri(args[1].replaceFirst(URI_PREFIX, StringUtils.EMPTY)); } else { List<String> argsList = new ArrayList<String>(Arrays.asList(args)); // remove first arg which is just the generic command "vsts" that got us to this point argsList.remove(0); processCommand(argsList); } } catch (Exception e) { logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, e.getMessage())); logMetrics(false, e.getClass().getSimpleName()); saveAll(); // exit code IntelliJ uses for exceptions System.exit(1); } catch (Throwable t) { logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, t.getMessage())); logMetrics(false, t.getClass().getSimpleName()); saveAll(); // exit code IntelliJ uses for throwables System.exit(2); } // log metrics and save settings before IDE closes logMetrics(true, null); saveAll(); }
From source file:de.tor.tribes.util.VillageUtils.java
public static Village[] getVillagesByTag(Tag[] pTags, Tribe pTribe, RELATION pRelation, boolean pWithBarbarians, Comparator pComparator) { if (pTags == null) { return new Village[0]; }//from w w w . ja v a2 s . c om List<Village> villages = new ArrayList<>(); HashMap<Village, Integer> usageCount = new HashMap<>(); for (Tag tag : pTags) { for (Integer id : tag.getVillageIDs()) { Village v = DataHolder.getSingleton().getVillagesById().get(id); if (pWithBarbarians || !v.getTribe().equals(Barbarians.getSingleton())) { if (pTribe == null || v.getTribe().getId() == pTribe.getId()) { usageCount.put(v, (usageCount.get(v) == null) ? 1 : usageCount.get(v) + 1); if (!villages.contains(v)) { villages.add(v); } } } } } if (pRelation.equals(RELATION.AND)) { //remove villages that are tagges by less tags than tagCount int tagAmount = pTags.length; for (Entry<Village, Integer> entry : usageCount.entrySet()) { if (entry.getValue() == null || entry.getValue() != tagAmount) { villages.remove(entry.getKey()); } } } if (pComparator != null) { Collections.sort(villages, pComparator); } return villages.toArray(new Village[villages.size()]); }
From source file:io.ecarf.core.term.TermPart.java
/** * Add the elements of this array as children nested according to their order in the array * @param parts//from w w w . j a va 2s. c o m */ public void addChildren(List<String> parts) { if (this.children == null) { this.children = new HashMap<>(); } String part = parts.remove(0); TermPart termPart = this.children.get(part); if (termPart == null) { termPart = new TermPart(part); this.children.put(part, termPart); } // do we have children if (!parts.isEmpty()) { termPart.addChildren(parts); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.selection.DeterministicTournamentSelection.java
@Override public List<Individual> operate(EvolutionaryAlgorithm algorithm, List<Individual> individuals) throws OperatorException { /* Check exceptions. */ if (individuals == null) { throw new OperatorException("DeterministicTournamentSelection - " + "Empty individuals"); }/*from ww w .j av a2s . c om*/ /* Contruct the selected list of individuals by tournament. */ List<Individual> selectedIndividuals = new ArrayList<Individual>(individuals.size()); /* For each individual */ for (int i = 0; i < individuals.size(); i++) { /* Get it. */ Individual currentInd = individuals.get(i); /* Construct a pool with the other individuals. We will choose * individuals from that pool so we ensure that the current individual * is chosen only once and therefore it does not compete with itself. */ List<Individual> pool = new ArrayList<Individual>(individuals.size()); pool.addAll(individuals); pool.remove(currentInd); /* Construct the tournament group. */ List<Individual> tournament = new ArrayList<Individual>(poolSize); tournament.add(currentInd); /* Add peers randomly to the tournament until the pool size * (group size) is reached. */ for (int j = 0; j < poolSize - 1; j++) { int ind = EAFRandom.nextInt(pool.size()); Individual peer = pool.get(ind); tournament.add(peer); pool.remove(peer); /* Don't consider the same individual again. */ } /* Perform tournament. */ BestIndividualSpecification spec = new BestIndividualSpecification(); Individual selected = spec.get(tournament, 1, algorithm.getComparator()).get(0); selectedIndividuals.add((Individual) selected.clone()); } return selectedIndividuals; }
From source file:main.Driver.java
/** * Given a primary queue, a reference leadsheet for chords, and a corpus of queue files, construct the result leadsheet from a series of randomly weighted interpolations of the primary queue towards the set of selected queues. * @param autoencoder// ww w. j a v a 2 s . c o m * @param autoencoderConnectomePath * @param primaryQueuePath * @param queueFolder * @param outputFilePath * @param chordSequence * @param numReferenceQueues * @param numCombinations * @param interpolationMagnitude */ public static void frankensteinTest(ProductCompressingAutoencoder autoencoder, String autoencoderConnectomePath, String primaryQueuePath, File queueFolder, String outputFilePath, LeadsheetDataSequence chordSequence, int numReferenceQueues, int numCombinations, double interpolationMagnitude) { LogTimer.startLog("Loading queues"); if (queueFolder.isDirectory()) { File[] queueFiles = queueFolder.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.contains(".q"); } }); List<File> fileList = new ArrayList<>(); for (File file : queueFiles) { fileList.add(file); } Collections.shuffle(fileList); int numSelectedFiles = (numReferenceQueues > queueFiles.length) ? queueFiles.length : numReferenceQueues; for (int i = 0; i < queueFiles.length - numSelectedFiles; i++) { fileList.remove(fileList.size() - 1); } List<FragmentedNeuralQueue> queuePopulation = new ArrayList<>(fileList.size()); String songTitle = "A mix of "; for (File file : fileList) { FragmentedNeuralQueue newQueue = new FragmentedNeuralQueue(); newQueue.initFromFile(file.getPath()); queuePopulation.add(newQueue); songTitle += file.getName().replaceAll(".q", "") + ", "; } LogTimer.endLog(); LeadsheetDataSequence outputSequence = chordSequence.copy(); LeadsheetDataSequence additionalOutput = chordSequence.copy(); for (int i = 1; i < numCombinations; i++) { outputSequence.concat(additionalOutput.copy()); } LeadsheetDataSequence decoderInputSequence = outputSequence.copy(); FragmentedNeuralQueue primaryQueue = new FragmentedNeuralQueue(); primaryQueue.initFromFile(primaryQueuePath); for (int i = 0; i < numCombinations; i++) { LogTimer.startLog("Performing queue interpolation..."); AVector combinationStrengths = Vector.createLength(queuePopulation.size()); Random vectorRand = new Random(i); for (int j = 0; j < combinationStrengths.length(); j++) { combinationStrengths.set(j, vectorRand.nextDouble()); } combinationStrengths.divide(combinationStrengths.elementSum()); FragmentedNeuralQueue currQueue = primaryQueue.copy(); for (int k = 0; k < combinationStrengths.length(); k++) { currQueue.basicInterpolate(queuePopulation.get(k), combinationStrengths.get(k) * interpolationMagnitude); } LogTimer.endLog(); autoencoder.setQueue(currQueue); refreshNetworkState(autoencoder, autoencoderConnectomePath); decodeToSequence(autoencoder, outputSequence, decoderInputSequence); } writeLeadsheetFile(outputSequence, outputFilePath, "_randomInterpSamples", songTitle); } else { throw new RuntimeException("Given queue folder is not a directory!"); } }
From source file:it.unibas.spicy.model.algebra.operators.NormalizeViewForExecutionPlan.java
private SetAlias findAndRemoveVariableToAdd(VariableJoinCondition joinToAdd, List<SetAlias> variablesToAdd) { int posOfFromVariable = containsVariableWithSameId(joinToAdd.getFromVariable(), variablesToAdd); if (posOfFromVariable != -1) { return variablesToAdd.remove(posOfFromVariable); }// w ww . j a va 2 s . c o m int posOfToVariable = containsVariableWithSameId(joinToAdd.getToVariable(), variablesToAdd); if (posOfToVariable != -1) { return variablesToAdd.remove(posOfToVariable); } return null; }