Skip to content

Commit f3788fb

Browse files
committed
add join() method to Int/Float/StringList
1 parent 311c5e3 commit f3788fb

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

core/src/processing/data/FloatList.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,20 @@ public FloatList getSubset(int start, int num) {
749749
}
750750

751751

752+
public String join(String separator) {
753+
if (count == 0) {
754+
return "";
755+
}
756+
StringBuilder sb = new StringBuilder();
757+
sb.append(data[0]);
758+
for (int i = 1; i < count; i++) {
759+
sb.append(separator);
760+
sb.append(data[i]);
761+
}
762+
return sb.toString();
763+
}
764+
765+
752766
@Override
753767
public String toString() {
754768
StringBuilder sb = new StringBuilder();

core/src/processing/data/IntList.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,20 @@ public IntList getSubset(int start, int num) {
757757
}
758758

759759

760+
public String join(String separator) {
761+
if (count == 0) {
762+
return "";
763+
}
764+
StringBuilder sb = new StringBuilder();
765+
sb.append(data[0]);
766+
for (int i = 1; i < count; i++) {
767+
sb.append(separator);
768+
sb.append(data[i]);
769+
}
770+
return sb.toString();
771+
}
772+
773+
760774
@Override
761775
public String toString() {
762776
StringBuilder sb = new StringBuilder();

core/src/processing/data/StringList.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,20 @@ public IntDict getOrder() {
688688
// }
689689

690690

691+
public String join(String separator) {
692+
if (count == 0) {
693+
return "";
694+
}
695+
StringBuilder sb = new StringBuilder();
696+
sb.append(data[0]);
697+
for (int i = 1; i < count; i++) {
698+
sb.append(separator);
699+
sb.append(data[i]);
700+
}
701+
return sb.toString();
702+
}
703+
704+
691705
@Override
692706
public String toString() {
693707
StringBuilder sb = new StringBuilder();

core/todo.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ X perhaps it's a getGraphics() issue?
2828
X when using increment() on IntList, make sure the index exists
2929
X automatically resize the list if necessary
3030
X (this is more in keeping with increment() in the Dict classes)
31+
X add join() method to Int/Float/StringList
3132

3233
cleaning
3334
X load/save methods.. is it save("blah.svg") or saveSVG("blah.svg")
@@ -41,6 +42,8 @@ _ https://github.com/processing/processing/issues/2012
4142
_ add option to have full screen span across screens
4243
_ display=all in cmd line
4344
_ sketchDisplay() -> 0 for all, or 1, 2, 3...
45+
_ add optional/default values for get methods in JSON
46+
_ add isNull() method back to JSONObject/Array
4447

4548
_ test PGraphicsRetina2D w/ 7u40
4649
_ make sure that 7u40 doesn't reintroduce starvation issue on retina Macs

0 commit comments

Comments
 (0)