mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 10:55:38 +01:00
remove contract(), add trim(array)
This commit is contained in:
@@ -4679,6 +4679,7 @@ public class PApplet extends Applet
|
||||
System.arraycopy(src, 0, dst, 0, Array.getLength(src));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
static public boolean[] expand(boolean list[]) {
|
||||
return expand(list, list.length << 1);
|
||||
@@ -4761,33 +4762,8 @@ public class PApplet extends Applet
|
||||
|
||||
//
|
||||
|
||||
static public boolean[] contract(boolean list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public byte[] contract(byte list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public char[] contract(char list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public int[] contract(int list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public float[] contract(float list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public String[] contract(String list[], int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
|
||||
static public Object contract(Object list, int newSize) {
|
||||
return expand(list, newSize);
|
||||
}
|
||||
// contract() has been removed in revision 0124, use subset() instead.
|
||||
// (expand() is also functionally equivalent)
|
||||
|
||||
//
|
||||
|
||||
@@ -4831,33 +4807,32 @@ public class PApplet extends Applet
|
||||
//
|
||||
|
||||
static public boolean[] shorten(boolean list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public byte[] shorten(byte list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public char[] shorten(char list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public int[] shorten(int list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public float[] shorten(float list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public String[] shorten(String list[]) {
|
||||
return contract(list, list.length-1);
|
||||
return subset(list, 0, list.length-1);
|
||||
}
|
||||
|
||||
static public Object shorten(Object list) {
|
||||
int length = Array.getLength(list);
|
||||
//Object b = Array.get(list, length - 1);
|
||||
return contract(list, length - 1);
|
||||
return subset(list, 0, length - 1);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -5243,6 +5218,20 @@ public class PApplet extends Applet
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trim the whitespace from a String array. This returns a new
|
||||
* array and does not affect the passed-in array.
|
||||
*/
|
||||
static public String[] trim(String[] array) {
|
||||
String[] outgoing = new String[array.length];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
outgoing[i] = array[i].replace('\u00A0', ' ').trim();
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Join an array of Strings together as a single String,
|
||||
* separated by the whatever's passed in for the separator.
|
||||
|
||||
@@ -13,8 +13,10 @@ X http://dev.processing.org/bugs/show_bug.cgi?id=465
|
||||
X fix from dave bollinger for the POSTERIZE filter
|
||||
X http://dev.processing.org/bugs/show_bug.cgi?id=399
|
||||
X fix PImage regression in 0124 and the cache crap
|
||||
X added a version of trim() that handles an entire array
|
||||
X removed contract(), one can use expand() and subset() instead
|
||||
|
||||
_ loadImage() requires an extension, maybe add a second version?
|
||||
X loadImage() requires an extension, maybe add a second version?
|
||||
X loadImage("blah", "jpg");
|
||||
X otherwise people have to use strange hacks to get around it
|
||||
X also chop off ? from url detritus
|
||||
|
||||
Reference in New Issue
Block a user