Here you can find the source of subtractQ(LinkedList
public static void subtractQ(LinkedList<Float> Q, List<Float> P)
//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); } }