From eb395cc679946acdd3869eeda0c407b338e5d483 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 28 Jan 2007 16:40:41 +0000 Subject: [PATCH] remove contract(), add trim(array) --- core/src/processing/core/PApplet.java | 59 +++++++++++---------------- core/todo.txt | 4 +- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 63411f2eb..2ba38a222 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -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. diff --git a/core/todo.txt b/core/todo.txt index 39424a4d7..182d1e3a0 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -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