Java List Subtract subtractQ(LinkedList Q, List P)

Here you can find the source of subtractQ(LinkedList Q, List P)

Description

subtract Q

License

GNU General Public License

Declaration

public static void subtractQ(LinkedList<Float> Q, List<Float> P) 

Method Source Code

//package com.java2s;
/*//from w  w  w . j  av a 2  s  .co m
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the GPL License.
 * See the accompanying LICENSE file for terms.
 */

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void subtractQ(LinkedList<Float> Q, List<Float> P) {
        Iterator<Float> it = P.iterator();
        float p = 0;
        LinkedList<Float> temp = new LinkedList<Float>();

        for (float q : Q) {
            if (it.hasNext()) {
                p = it.next();
            }

            temp.addLast(q - p);
        }

        Q.clear();
        Q.addAll(temp);
    }
}

Related

  1. subtract(List aList, List bList)
  2. subtract(String[] list1, String[] list2)
  3. subtractAsList(T[] array1, T[] array2)
  4. subtractFloatLists(List listA, List listB)
  5. subtractFromList(List op1, Object op2)