Example usage for java.util List set

List of usage examples for java.util List set

Introduction

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

Prototype

E set(int index, E element);

Source Link

Document

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

Usage

From source file:delfos.rs.contentbased.vsm.booleanvsm.BooleanFeaturesTransformation.java

public List<Double> getDoubleValuesVector(BooleanUserProfile booleanUserProfile) {
    List<Double> ret = new ArrayList<>(numFeatures);
    for (int i = 0; i < numFeatures; i++) {
        ret.add(0.0);// w  ww . j  a  v a  2  s.c o m
    }

    for (Feature feature : booleanUserProfile.getFeatures()) {
        for (Object featureValue : booleanUserProfile.getValuedFeatureValues(feature)) {
            long idFeatureValue = getFeatureIndex(feature, featureValue);
            double featureValueValue = booleanUserProfile.getFeatureValueValue(feature, featureValue);

            ret.set((int) idFeatureValue, (double) featureValueValue);
        }
    }

    return ret;
}

From source file:delfos.rs.contentbased.vsm.booleanvsm.BooleanFeaturesTransformation.java

public List<Double> getDoubleWeightsVector(BooleanUserProfile booleanUserProfile) {
    List<Double> ret = new ArrayList<>(numFeatures);
    for (int i = 0; i < numFeatures; i++) {
        ret.add(0.0);/*w  w w . j  a v a2s . c  o m*/
    }

    for (Feature feature : booleanUserProfile.getFeatures()) {
        for (Object featureValue : booleanUserProfile.getValuedFeatureValues(feature)) {
            long idFeatureValue = getFeatureIndex(feature, featureValue);
            double featureValueValue = booleanUserProfile.getFeatureValueWeight(feature, featureValue);

            ret.set((int) idFeatureValue, (double) featureValueValue);
        }
    }

    return ret;
}

From source file:net.lightbody.bmp.proxy.jetty.http.HttpFields.java

/** List values in quality order.
 * @param enm Enumeration of values with quality parameters
 * @return values in quality order./* w  w  w.  j  a  va2  s .  c  o m*/
 */
public static List qualityList(Enumeration enm) {
    if (enm == null || !enm.hasMoreElements())
        return Collections.EMPTY_LIST;

    Object list = null;
    Object qual = null;

    // Assume list will be well ordered and just add nonzero
    while (enm.hasMoreElements()) {
        String v = enm.nextElement().toString();
        Float q = getQuality(v);

        if (q.floatValue() >= 0.001) {
            list = LazyList.add(list, v);
            qual = LazyList.add(qual, q);
        }
    }

    List vl = LazyList.getList(list, false);
    if (vl.size() < 2)
        return vl;

    List ql = LazyList.getList(qual, false);

    // sort list with swaps
    Float last = __zero;
    for (int i = vl.size(); i-- > 0;) {
        Float q = (Float) ql.get(i);
        if (last.compareTo(q) > 0) {
            Object tmp = vl.get(i);
            vl.set(i, vl.get(i + 1));
            vl.set(i + 1, tmp);
            ql.set(i, ql.get(i + 1));
            ql.set(i + 1, q);
            last = __zero;
            i = vl.size();
            continue;
        }
        last = q;
    }
    ql.clear();
    return vl;
}

From source file:com.iksgmbh.sql.pojomemodb.sqlparser.SelectParser.java

private void replaceAliasInSelectClause(final List<String> selectedColumns,
        final List<TableId> selectedTables) {
    if (selectedColumns != null) {
        int i = -1;
        for (String columnName : selectedColumns) {
            i++;//from w  w  w  . ja  v a 2 s. c  om
            for (TableId tableId : selectedTables) {
                final String firstPartOfColumnId = tableId.getAlias() + ".";
                if (columnName.startsWith(firstPartOfColumnId)) {
                    selectedColumns.set(i,
                            columnName.replace(firstPartOfColumnId, tableId.getTableName() + "."));
                }
            }
        }
    }
}

From source file:net.sf.jabb.util.web.WebApplicationConfiguration.java

/**
 * Convert MenuItemExt to WebMenuItem, and clean up all data
 * @param root/*  ww w. java  2s  .  c o m*/
 */
protected void cleanUpMenuTree(WebMenuItem root, String menuName) {
    List<WebMenuItem> subMenu = root.getSubMenu();
    List<WebMenuItem> rootBreadcrumbs = root.getBreadcrumbs();
    if (subMenu != null && subMenu.size() > 0) {
        Collections.sort(subMenu);
        for (int i = 0; i < subMenu.size(); i++) {
            WebMenuItem item = subMenu.get(i);
            if (item instanceof MenuItemExt) {
                MenuItemExt itemExt = (MenuItemExt) item;
                item = itemExt.toWebMenuItem();
                subMenu.set(i, item);
                menuItemPaths.get(menuName).put(itemExt.path, item);
            }
            item.breadcrumbs = new ArrayList<WebMenuItem>();
            if (rootBreadcrumbs != null) {
                item.breadcrumbs.addAll(rootBreadcrumbs);
            }
            item.breadcrumbs.add(item);
            cleanUpMenuTree(item, menuName);
        }
    }
}

From source file:com.opengamma.analytics.financial.credit.schedulegeneration.isda.ISDAPremiumLegScheduleGenerator.java

public ZonedDateTime[] constructISDACompliantCreditDefaultSwapPremiumLegSchedule(
        final CreditDefaultSwapDefinition cds) {
    ArgumentChecker.notNull(cds, "cds");
    final ZonedDateTime startDate = cds.getStartDate();
    final ZonedDateTime endDate = cds.getMaturityDate();
    final boolean protectStart = cds.getProtectionStart();
    final StubType stubType = cds.getStubType();
    if (protectStart && endDate.equals(startDate)) {
        //note no adjustment of either date
        return new ZonedDateTime[] { startDate, startDate.plusDays(1) };
    }/*  w w w . j av  a 2s .  co m*/
    // Is the stub at the front end of the payment schedule
    if (stubType == StubType.FRONTSHORT || stubType == StubType.FRONTLONG) {
        final List<ZonedDateTime> reversedCashflowSchedule = new ArrayList<>();
        ZonedDateTime date = endDate;
        while (date.isAfter(startDate)) {
            reversedCashflowSchedule.add(date);
            date = date.minus(cds.getCouponFrequency().getPeriod());
        }
        // TODO : Check the FRONTSHORT/FRONTLONG logic here
        if (reversedCashflowSchedule.size() == 1 || date.isEqual(startDate)
                || stubType == StubType.FRONTSHORT) {
            reversedCashflowSchedule.add(startDate);
        } else {
            reversedCashflowSchedule.set(reversedCashflowSchedule.size() - 1, startDate);
        }
        //TODO this logic assumes list was populated with decreasing dates
        final int nDatesInSchedule = reversedCashflowSchedule.size();
        final ZonedDateTime[] cashflowSchedule = new ZonedDateTime[nDatesInSchedule];
        //TODO not handling protectStart
        // Remember if protectStart = TRUE then there is an extra day of accrued that is not captured here
        cashflowSchedule[nDatesInSchedule - 1] = reversedCashflowSchedule.get(0);
        final Calendar calendar = cds.getCalendar();
        final BusinessDayConvention bdc = cds.getBusinessDayAdjustmentConvention();
        for (int i = nDatesInSchedule - 2; i > 0; i--) {
            cashflowSchedule[nDatesInSchedule - i - 1] = bdc.adjustDate(calendar,
                    reversedCashflowSchedule.get(i));
        }
        cashflowSchedule[0] = reversedCashflowSchedule.get(nDatesInSchedule - 1);
        return cashflowSchedule;
    }
    // TODO : Add the code for the back stub
    // Is the stub at the back end of the payment schedule
    throw new NotImplementedException();
}

From source file:com.haulmont.cuba.gui.components.filter.edit.FilterEditor.java

public void moveConditionUp() {
    AbstractCondition condition = conditionsDs.getItem();
    Node<AbstractCondition> node = conditions.getNode(condition);

    List<Node<AbstractCondition>> siblings = node.getParent() == null ? conditions.getRootNodes()
            : node.getParent().getChildren();

    int idx = siblings.indexOf(node);
    if (idx > 0) {
        Node<AbstractCondition> prev = siblings.get(idx - 1);
        siblings.set(idx - 1, node);
        siblings.set(idx, prev);/*from w  ww  .  ja v  a 2  s . c o m*/
        refreshConditionsDs();
        conditionsTree.setSelected(condition);
    }
}

From source file:com.indeed.imhotep.sql.IQLTranslator.java

private static void optimizeGroupings(List<Grouping> groupings) {
    // if we have only one grouping we can safely disable exploding which allows us to stream the result
    if (groupings.size() == 1 && groupings.get(0) instanceof FieldGrouping) {
        FieldGrouping fieldGrouping = (FieldGrouping) groupings.get(0);
        if (!fieldGrouping.isNoExplode() && !fieldGrouping.isTopK() && !fieldGrouping.isTermSubset()) {
            groupings.set(0, new FieldGrouping(fieldGrouping.getField(), true));
        }/*ww w  . j a  v  a  2s.  co  m*/
    }
}

From source file:com.faujnet.mongo.repository.MongoConnectionRepository.java

/**
 * Find the connections the current user has to the given provider users. 
 *///  w w w . jav a2 s .  c  o m
@Override
public MultiValueMap<String, Connection<?>> findConnectionsToUsers(
        MultiValueMap<String, String> providerUsers) {
    if (providerUsers == null || providerUsers.isEmpty()) {
        throw new IllegalArgumentException("Unable to execute find: no providerUsers provided");
    }

    List<Connection<?>> resultList = connService.getConnections(userId, providerUsers);

    MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<String, Connection<?>>();
    for (Connection<?> connection : resultList) {
        String providerId = connection.getKey().getProviderId();
        List<String> userIds = providerUsers.get(providerId);
        List<Connection<?>> connections = connectionsForUsers.get(providerId);
        if (connections == null) {
            connections = new ArrayList<Connection<?>>(userIds.size());
            for (int i = 0; i < userIds.size(); i++) {
                connections.add(null);
            }
            connectionsForUsers.put(providerId, connections);
        }
        String providerUserId = connection.getKey().getProviderUserId();
        int connectionIndex = userIds.indexOf(providerUserId);
        connections.set(connectionIndex, connection);
    }
    return connectionsForUsers;
}

From source file:booknext.DatabaseSetup.java

public List<String> BubbleSort(List<Integer> num, List<String> words) {
    int j;//from w  w  w  . j a v a 2 s.  c  o m
    boolean flag = true; // set flag to true to begin first pass
    int temp; //holding variable
    String temps;

    while (flag) {
        flag = false; //set flag to false awaiting a possible swap
        for (j = 0; j < num.size() - 1; j++) {
            if (num.get(j) < num.get(j + 1)) // change to > for ascending sort
            {
                temp = num.get(j);
                temps = words.get(j); //swap elements

                num.set(j, num.get(j + 1));
                words.set(j, words.get(j + 1));

                num.set(j + 1, temp);
                words.set(j + 1, temps);

                flag = true; //shows a swap occurred  
            }
        }
    }
    return words;
}