Skip to content

Commit ebf5dba

Browse files
committed
add sum() to IntList and FloatList (#1893)
1 parent 6819c87 commit ebf5dba

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

core/src/processing/data/FloatList.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,15 @@ public int maxIndex() {
533533
}
534534

535535

536+
public float sum() {
537+
double outgoing = 0;
538+
for (int i = 0; i < count; i++) {
539+
outgoing += data[i];
540+
}
541+
return (float) outgoing;
542+
}
543+
544+
536545
/**
537546
* Sorts the array in place.
538547
*

core/src/processing/data/IntList.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,15 @@ public int maxIndex() {
499499
}
500500

501501

502+
public int sum() {
503+
int outgoing = 0;
504+
for (int i = 0; i < count; i++) {
505+
outgoing += data[i];
506+
}
507+
return outgoing;
508+
}
509+
510+
502511
/**
503512
* Sorts the array in place.
504513
*

core/todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ X prevents speed/performance issues with old sketches on retina macs
1818
X add error message for raspberry pi (and others?) about int buffers
1919
X https://github.com/processing/processing/issues/2010
2020
X not fixed, but made notes there about how to handle
21+
X add sum() to IntList and FloatList
22+
X https://github.com/processing/processing/issues/1893
2123

2224
_ add option to have full screen span across screens
2325
_ display=all in cmd line

0 commit comments

Comments
 (0)