FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixes for getSubset() (#1979) · appsou/processing@a307092 · GitHub

Repository navigation

Commit a307092

Browse files
committed
fixes for getSubset() (processing#1979)
1 parent eb7c654 commit a307092

3 files changed

Lines changed: 28 additions & 19 deletions

File tree

‎core/src/processing/data/FloatList.java‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,17 +577,18 @@ public void swap(int a, int b) {
577577
// }
578578

579579

580-
public void subset(int start) {
581-
subset(start, count - start);
582-
}
580+
// public void subset(int start) {
581+
// subset(start, count - start);
582+
// }
583583

584584

585-
public void subset(int start, int num) {
586-
for (int i = 0; i < num; i++) {
587-
data[i] = data[i+start];
588-
}
589-
count = num;
590-
}
585+
// public void subset(int start, int num) {
586+
// for (int i = 0; i < num; i++) {
587+
// data[i] = data[i+start];
588+
// }
589+
// count = num;
590+
// }
591+
591592

592593
/**
593594
* @webref floatlist:method
@@ -707,6 +708,18 @@ public float[] array(float[] array) {
707708
}
708709

709710

711+
public FloatList getSubset(int start) {
712+
return getSubset(start, count - start);
713+
}
714+
715+
716+
public FloatList getSubset(int start, int num) {
717+
float[] subset = new float[num];
718+
System.arraycopy(data, start, subset, 0, num);
719+
return new FloatList(subset);
720+
}
721+
722+
710723
@Override
711724
public String toString() {
712725
StringBuilder sb = new StringBuilder();

‎core/src/processing/data/IntList.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,9 @@ public IntList getSubset(int start) {
704704

705705

706706
public IntList getSubset(int start, int num) {
707-
IntList outgoing = new IntList(num);
708-
for (int i = 0; i < num; i++) {
709-
System.arraycopy(data, start, outgoing.data, 0, num);
710-
}
711-
return outgoing;
707+
int[] subset = new int[num];
708+
System.arraycopy(data, start, subset, 0, num);
709+
return new IntList(subset);
712710
}
713711

714712

‎core/src/processing/data/StringList.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,9 @@ public StringList getSubset(int start) {
648648

649649

650650
public StringList getSubset(int start, int num) {
651-
StringList outgoing = new StringList(num);
652-
for (int i = 0; i < num; i++) {
653-
System.arraycopy(data, start, outgoing.data, 0, num);
654-
}
655-
return outgoing;
651+
String[] subset = new String[num];
652+
System.arraycopy(data, start, subset, 0, num);
653+
return new StringList(subset);
656654
}
657655

658656

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL