Example usage for java.util List remove

List of usage examples for java.util List remove

Introduction

In this page you can find the example usage for java.util List remove.

Prototype

E remove(int index);

Source Link

Document

Removes the element at the specified position in this list (optional operation).

Usage

From source file:de.l3s.archivepig.DataEvalFunc.java

@Override
public T exec(Tuple tuple) throws ExecException {
    List<Object> params = tuple.getAll();
    Tuple data = (Tuple) params.remove(0);

    return exec(data, array(params));
}

From source file:forge.game.combat.CombatUtil.java

/**
 * <p>/* w  ww  . jav a2s . c o m*/
 * This method checks triggered effects of attacking creatures, right before
 * defending player declares blockers.
 * </p>
 * @param game
 * 
 * @param c
 *            a {@link forge.game.card.Card} object.
 */
public static void checkDeclaredAttacker(final Game game, final Card c, final Combat combat) {
    // Run triggers
    final Map<String, Object> runParams = Maps.newHashMap();
    runParams.put("Attacker", c);
    final List<Card> otherAttackers = combat.getAttackers();
    otherAttackers.remove(c);
    runParams.put("OtherAttackers", otherAttackers);
    runParams.put("Attacked", combat.getDefenderByAttacker(c));
    runParams.put("DefendingPlayer", combat.getDefenderPlayerByAttacker(c));
    game.getTriggerHandler().runTrigger(TriggerType.Attacks, runParams, false);

    // Annihilator: can be copied by Strionic Resonator now
    if (!c.getDamageHistory().getCreatureAttackedThisCombat()) {
        for (final String key : c.getKeywords()) {
            if (!key.startsWith("Annihilator "))
                continue;
            final String[] k = key.split(" ", 2);

            final String sb = "Annihilator - Defending player sacrifices " + k[1] + " permanents.";
            final String effect = "AB$ Sacrifice | Cost$ 0 | Defined$ DefendingPlayer | SacValid$ Permanent | Amount$ "
                    + k[1];

            final SpellAbility ability = AbilityFactory.getAbility(effect, c);
            ability.setActivatingPlayer(c.getController());
            ability.setDescription(sb);
            ability.setStackDescription(sb);
            ability.setTrigger(true);

            game.getStack().addSimultaneousStackEntry(ability);

        }
    }

    c.getDamageHistory().setCreatureAttackedThisCombat(true);
    c.getDamageHistory().clearNotAttackedSinceLastUpkeepOf();
    c.getController().setAttackedWithCreatureThisTurn(true);
    c.getController().incrementAttackersDeclaredThisTurn();
}

From source file:com.nec.harvest.junit4.BaseTest.java

protected void assertListEqual(List<?> actual, Object... expected) {
    Assert.assertEquals("The list did not have the expected length", expected.length, actual.size());

    List<Object> remaining = new LinkedList<Object>();
    remaining.addAll(actual);//from   w w  w .  ja  va  2s .c  o  m

    for (Object o : expected) {
        if (!remaining.remove(o))
            Assert.fail("The list did not match the expected results.");
    }
}

From source file:cz.muni.fi.dndtroops.service.HeroServiceImpl.java

@Override
public void removeTroop(Hero hero) {
    log.debug("removeTroop({})", hero);
    if (hero.getTroop() == null) {
        throw new DnDTroopServiceException("Hero not in troop.");
    }//from   w w  w  .  ja  v a 2s. c  o  m
    try {
        Troop t = hero.getTroop();
        List<Hero> list = t.getMembers();
        list.remove(hero);
        t.setMembers(list);
        hero.setTroop(null);
    } catch (Exception ex) {
        throw new DnDTroopServiceException("removeTroop problem", ex);
    }

}

From source file:it.larusba.neo4j.jdbc.http.test.Neo4jHttpUnitTest.java

/**
 * Retrieve some random queries from a csv file.
 * We return a map with the CSV source into the kye <code>source</code> and its object Neo4jStatement into key <code>object</code>.
 *
 * @param filename  The filename that contains queries
 * @param nbElement The number element to return
 * @return//from  ww w.j a v a 2s.c o  m
 * @throws Exception
 */
protected Map<String, List> getRandomNeo4jStatementFromCSV(String filename, int nbElement) throws Exception {
    List<Neo4jStatement> queriesObj = new ArrayList<>();
    List<String[]> queriesCsv = new ArrayList<>();

    File csv = new File(getClass().getClassLoader().getResource(filename).getFile());
    CSVReader reader = new CSVReader(new FileReader(csv), ';', '"');
    List<String[]> entries = reader.readAll();
    entries.remove(0); // remove headers

    if (nbElement > 0) {
        Random random = new Random();
        for (int i = 0; i < nbElement; i++) {
            Integer id = random.nextInt(entries.size());
            String[] line = entries.get(id);
            queriesObj.add(transformCsvLineToNeo4jStatement(line));
            queriesCsv.add(line);
        }
    } else {
        for (String[] line : entries) {
            queriesObj.add(transformCsvLineToNeo4jStatement(line));
            queriesCsv.add(line);
        }
    }

    Map<String, List> result = new HashMap<>();
    result.put("source", queriesCsv);
    result.put("object", queriesObj);

    return result;
}

From source file:iqq.app.core.service.impl.EventServiceImpl.java

@Override
public void unregister(UIEventType[] intrestedEvents, UIEventListener listener) {
    for (UIEventType type : intrestedEvents) {
        List<UIEventListener> list = lookup.get(type);
        if (list != null) {
            list.remove(listener);
        }//from  w w  w . j a v  a  2s  . c o m
    }
}

From source file:it.unibas.spicy.model.paths.operators.FindPathsInVariable.java

public void visitVariable(SetAlias variable) {
    if (logger.isDebugEnabled())
        logger.debug("Extracting attributes from variable: " + variable);
    VariablePathExpression pathExpression = variable.getBindingPathExpression();
    pathExpression.accept(this);
    List<VariablePathExpression> relativePaths = pathGenerator
            .generateFirstLevelChildrenRelativePaths(pathExpression, root);
    for (VariablePathExpression relativePath : relativePaths) {
        List<String> pathSteps = relativePath.getPathSteps();
        pathSteps.remove(0);
        result.add(new VariablePathExpression(variable, pathSteps));
    }// www . j a v  a2 s. co  m
    if (logger.isDebugEnabled())
        logger.debug("Extracted attributes: " + result);
}

From source file:com.centeractive.ws.legacy.SchemaUtils.java

public static SchemaTypeSystem buildSchemaTypes(List<XmlObject> schemas) {
    XmlOptions options = new XmlOptions();
    options.setCompileNoValidation();/*from w w w  . ja v a2s. co  m*/
    options.setCompileNoPvrRule();
    options.setCompileDownloadUrls();
    options.setCompileNoUpaRule();
    options.setValidateTreatLaxAsSkip();

    for (int c = 0; c < schemas.size(); c++) {
        XmlObject xmlObject = schemas.get(c);
        if (xmlObject == null || !((Document) xmlObject.getDomNode()).getDocumentElement().getNamespaceURI()
                .equals(Constants.XSD_NS)) {
            schemas.remove(c);
            c--;
        }
    }

    // TODO
    boolean strictSchemaTypes = STRICT_SCHEMA_TYPES;//SoapUI.getSettings().getBoolean( WsdlSettings.STRICT_SCHEMA_TYPES );
    if (!strictSchemaTypes) {
        Set<String> mdefNamespaces = new HashSet<String>();

        for (XmlObject xObj : schemas) {
            mdefNamespaces.add(getTargetNamespace(xObj));
        }

        options.setCompileMdefNamespaces(mdefNamespaces);
    }

    ArrayList<?> errorList = new ArrayList<Object>();
    options.setErrorListener(errorList);

    XmlCursor cursor = null;

    try {
        // remove imports
        for (int c = 0; c < schemas.size(); c++) {
            XmlObject s = schemas.get(c);

            Map<?, ?> map = new HashMap<String, String>();
            cursor = s.newCursor();
            cursor.toStartDoc();
            if (toNextContainer(cursor)) {
                cursor.getAllNamespaces(map);
            } else {
                log.warn("Can not get namespaces for " + s);
            }

            String tns = getTargetNamespace(s);

            // log.info( "schema for [" + tns + "] contained [" + map.toString()
            // + "] namespaces" );

            if (strictSchemaTypes && defaultSchemas.containsKey(tns)) {
                schemas.remove(c);
                c--;
            } else {
                removeImports(s);
            }

            cursor.dispose();
            cursor = null;
        }

        // schemas.add( soapVersion.getSoapEncodingSchema());
        // schemas.add( soapVersion.getSoapEnvelopeSchema());
        schemas.addAll(defaultSchemas.values());

        SchemaTypeSystem sts = XmlBeans.compileXsd(schemas.toArray(new XmlObject[schemas.size()]),
                XmlBeans.getBuiltinTypeSystem(), options);

        return sts;
        // return XmlBeans.typeLoaderUnion(new SchemaTypeLoader[] { sts,
        // XmlBeans.getBuiltinTypeSystem() });
    } catch (Exception e) {
        throw new SoapBuilderException(e);
    } finally {
        for (int c = 0; c < errorList.size(); c++) {
            log.warn("Error: " + errorList.get(c));
        }

        if (cursor != null) {
            cursor.dispose();
        }
    }
}

From source file:io.dockstore.client.cli.Client.java

private static void dev(final List<String> args) throws ApiException {
    if (isHelp(args, true)) {
        out("");/*ww  w. j a v  a2 s  .  c  om*/
        out("Usage: dockstore dev --help");
        out("       dockstore dev cwl2json");
        out("       dockstore dev tool2json <container>");
        out("");
        out("Description:");
        out("  Experimental features not quite ready for prime-time.");
        out("");
    } else {
        String cmd = args.remove(0);
        if (null != cmd) {
            switch (cmd) {
            case "cwl2json":
                cwl2json(args);
                break;
            case "tool2json":
                tool2json(args);
                break;
            default:
                invalid(cmd);
                break;
            }
        }
    }
}

From source file:angel.zhuoxiu.library.pusher.PusherChannel.java

@Override
public void unbind(PusherCallback callback) {
    /* remove all matching callbacks from the global callback list */
    while (mGlobalCallbacks.remove(callback))
        ;/* w  w  w  .j a  v a 2  s .  co m*/

    /* remove all matching callbacks from each local callback list */
    for (List<PusherCallback> localCallbacks : mLocalCallbacks.values()) {
        while (localCallbacks.remove(callback))
            ;
    }
}