List of utility methods to do List Sum
List | sumAllColumnsOfMatrix(List
sum All Columns Of Matrix List<Integer> result = new ArrayList<Integer>(); for (int i = 0; i < matrix.size(); i++) { Integer columnTotal = 0; for (int j = 0; j < matrix.size(); j++) List<Integer> row = matrix.get(j); for (int k = 0; k < row.size(); k++) if (k == i) { columnTotal = (columnTotal + row.get(k)) % 26; break; result.add(columnTotal); return result; |
String | sumCreditList(List Creates the sum of a list of credit ranges, returning the cumulative min and max credits eg "1-2", "3-5" would return "4-7" if (list == null || list.isEmpty()) return "0"; float minCredits = 0; float maxCredits = 0; for (String item : list) { String[] split = item.split("[ ,/-]"); String first = split[0]; float min = Float.parseFloat(first); ... |
float | sumDifferences(List sum Differences assert (a.size() == b.size()); float sumDiff = 0f; for (int i = 0; i < a.size(); i++) { sumDiff += Math.abs(a.get(i) - b.get(i)); return (float) sumDiff; |
double | sumDouble(List sum Double double sum = 0; for (Double i : list) { if (i != null) sum += i; return sum; |
int | sumInteger(List sum Integer int accumulator = 0; if (list instanceof RandomAccess) { for (int i = 0; i < list.size(); i++) { accumulator += list.get(i); } else { Iterator<Integer> iter = list.iterator(); while (iter.hasNext()) ... |
int | sumIntegers(List sum Integers int s = 0; for (int v : values) s += v; return s; |
String | sumListItems(List list) sum List Items double sum = 0d; for (int i = 0; i < list.size(); i++) { String value = (String) list.get(i); if (value == null || "".equals(value)) continue; sum = sum + Double.parseDouble(value); return String.valueOf(sum); ... |
float | sumLog(List sum Log float res = 0; for (float f : Q) { res += Math.log(f); return res; |
long | sumLong(List Sum long. long sum = 0; for (int i = 0; i < list.size(); i++) { sum += list.get(i); return sum; |
double | sumOfSquares(List sum Of Squares double sumOfSquares = 0; for (double sample : samples) { sumOfSquares += sample * sample; return sumOfSquares; |