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:cool.pandora.modeller.ui.handlers.common.NodeMap.java

/**
 * getWordIdMap./*from  ww w  .j av  a 2s  .co m*/
 *
 * @param hocr       hOCRData
 * @param lineIdList List
 * @return Map
 */
public static Map<String, List<String>> getWordIdMap(final hOCRData hocr, final List<String> lineIdList) {
    final Map<String, List<String>> nodemap = new HashMap<>();
    List<String> wordIdList;
    for (String lineId : lineIdList) {
        wordIdList = getWordIdListforLine(hocr, lineId);
        for (int i = 0; i < wordIdList.size(); i++) {
            final String wordId = StringUtils.substringAfter(wordIdList.get(i), "_");
            wordIdList.set(i, wordId);
        }
        lineId = StringUtils.substringAfter(lineId, "_");
        nodemap.put(lineId, wordIdList);
    }
    return nodemap;
}

From source file:cool.pandora.modeller.ui.handlers.common.NodeMap.java

/**
 * getWordsForPageMap.//from   w ww .j  a v a 2  s  . c om
 *
 * @param hocr       hOCRData
 * @param pageIdList List
 * @return Map
 */
public static Map<String, List<String>> getWordsForPageMap(final hOCRData hocr, final List<String> pageIdList) {
    final Map<String, List<String>> nodemap = new HashMap<>();
    List<String> wordIdList;
    for (String pageId : pageIdList) {
        wordIdList = getWordIdListforPage(hocr, pageId);
        for (int i = 0; i < wordIdList.size(); i++) {
            final String wordId = StringUtils.substringAfter(wordIdList.get(i), "_");
            wordIdList.set(i, wordId);
        }
        pageId = StringUtils.substringAfter(pageId, "_");
        nodemap.put(pageId, wordIdList);
    }
    return nodemap;
}

From source file:com.none.tom.simplerssreader.utils.SharedPrefUtils.java

@SuppressWarnings("ConstantConditions")
public static void updateSubscriptionIdAt(final Context context, final String id, final int position) {
    final LinkedListMultimap<String, String> subscriptions = getSubscriptions(context);

    final String title = getSubscriptionTitleAt(context, position);
    final List<String> values = subscriptions.get(title);

    values.set(1, id);
    subscriptions.replaceValues(title, values);

    saveSubscriptions(context, subscriptions);
}

From source file:com.none.tom.simplerssreader.utils.SharedPrefUtils.java

@SuppressWarnings("ConstantConditions")
public static void updateSubscriptionUrl(final Context context, final String feedUrl) {
    final LinkedListMultimap<String, String> subscriptions = getSubscriptions(context);

    final int position = getCurrentFeedPosition(context);
    final String title = getSubscriptionTitleAt(context, position);

    final List<String> values = subscriptions.get(title);

    values.set(2, feedUrl);
    subscriptions.replaceValues(title, values);

    saveSubscriptions(context, subscriptions);
}

From source file:it.incipict.tool.profiles.util.ProfilesToolUtils.java

public static Survey webAppProfilerManagerAssoc(final Survey survey) {
    if (!WEBASSOC_MODE)
        return survey;
    else {//www  . j  a v a  2s. c om
        // Make a copy of the survey
        Survey result = new Survey(survey);
        List<Double> answersRealVector = result.getAnswersRealVector();
        System.out.println("\n[1] " + answersRealVector.toString());

        int index = 0;
        for (Double d : answersRealVector) {
            if (d > 0.7)
                answersRealVector.set(index++, 1.0);
            else
                answersRealVector.set(index++, 0.0);
        }
        result.setAnswersRealVector(answersRealVector);
        System.out.println("[2] " + answersRealVector.toString());
        return result;
    }
}

From source file:Main.java

public static <E> E setInSortedList(List<E> list, int index, E item, Comparator<? super E> comparator,
        BiPredicate<? super E, ? super E> distincter) {
    if (distincter != null) {
        ListIterator<E> iter = list.listIterator();
        while (iter.hasNext()) {
            int currIndex = iter.nextIndex();
            E currItem = iter.next();/*from w w  w .java  2  s.c  om*/
            if (index != currIndex && distincter.test(currItem, item)) {
                return null;
            }
        }
    }
    E previousItem = list.set(index, item);
    list.sort(comparator);
    return previousItem;
}

From source file:com.flipkart.zjsonpatch.JsonDiff.java

private static void updatePathWithCounters(List<Integer> counters, List<Object> path) {
    for (int i = 0; i < counters.size(); i++) {
        int value = counters.get(i);
        if (value != 0) {
            Integer currValue = Integer.parseInt(path.get(i).toString());
            path.set(i, String.valueOf(currValue + value));
        }//ww  w. j  a v  a 2  s. c  om
    }
}

From source file:StringUtilities.java

/**
 * Adds an header to the provided map of headers.
 * //from  w w  w .  ja  v a2 s  .c o m
 * @param headers the http headers map
 * @param key the name of the new header to add
 * @param value the value of the added header
 * @param singleValued if true and the map already contains one value
 * then it is replaced by the new value. Otherwise it simply adds a new
 * value to this multi-valued header.
 */
public static void addValueToHeader(Map<String, List<String>> headers, String key, String value,
        boolean singleValued) {
    List<String> values = headers.get(key);

    if (values == null) {
        values = new ArrayList<String>(1);
        headers.put(key, values);
    }

    if (singleValued && values.size() == 1) {
        values.set(0, value);
    } else {
        values.add(value);
    }
}

From source file:Main.java

private static <T> int partition(List<T> list, int lo, int hi, Comparator<T> comparator) {
    T pivot = list.get(lo);/* w  ww .j  ava2 s.c  om*/
    int i = lo - 1;
    int j = hi + 1;
    while (true) {
        do {
            i++;
        } while (compare(list.get(i), pivot, comparator) < 0);
        do {
            j--;
        } while (compare(list.get(j), pivot, comparator) > 0);
        if (i >= j) {
            return j;
        }
        T swap = list.get(i);
        list.set(i, list.get(j));
        list.set(j, swap);
    }
}

From source file:com.github.steveash.jg2p.seq.PhonemeCrfTrainer.java

private static void updateEpsilons(List<String> phones) {
    String last = EPS;/*w  w w .  j av  a2  s  .  c  o m*/
    int blankCount = 0;
    for (int i = 0; i < phones.size(); i++) {
        String p = phones.get(i);
        if (isBlank(p)) {
            //        phones.set(i, last + "_" + blankCount);
            phones.set(i, EPS);
            blankCount += 1;
        } else {
            last = p;
            blankCount = 0;
        }
    }
}