diff --git a/processing/core/PApplet.java b/processing/core/PApplet.java index 223e690e3..19eb1c966 100644 --- a/processing/core/PApplet.java +++ b/processing/core/PApplet.java @@ -3586,13 +3586,11 @@ public class PApplet extends Applet } - public Object expand(Object array) { + static public Object expand(Object array) { return expand(array, Array.getLength(array) << 1); } - public Object expand(Object list, int newSize) { - System.out.println("using object expand"); - + static public Object expand(Object list, int newSize) { Class type = list.getClass().getComponentType(); Object temp = Array.newInstance(type, newSize); System.arraycopy(list, 0, temp, 0, @@ -3626,6 +3624,10 @@ public class PApplet extends Applet return expand(list, newSize); } + static public Object contract(Object list, int newSize) { + return expand(list, newSize); + } + // static public byte[] append(byte b[], byte value) { @@ -3658,6 +3660,14 @@ public class PApplet extends Applet return b; } + /* + static public Object append(Object b, Object value) { + b = expand(b, b.length + 1); + b[b.length-1] = value; + return b; + } + */ + // static public boolean[] shorten(boolean list[]) { @@ -3684,6 +3694,12 @@ public class PApplet extends Applet return contract(list, list.length-1); } + /* + static public Object shorten(Object list) { + return contract(list, list.length-1); + } + */ + // static final public boolean[] splice(boolean list[], diff --git a/processing/core/todo.txt b/processing/core/todo.txt index f88619da3..f9a6efb29 100644 --- a/processing/core/todo.txt +++ b/processing/core/todo.txt @@ -1,5 +1,12 @@ 0086 core +X typed version of expand() and contract() +_ need to complete for the others: +_ append(), shorten(), splice, slice, subset, concat, reverse + +_ would be cool if could sort w/o the sort class.. +_ meaning use reflection to sort objects, just by implementing a few methods + _ make a PException that extends RuntimeException but packages an ex? _ new PGraphics2 objects are set as RGB, but on loadPixels/updatePixels _ they're drawn as transparent and don't have their high bits set @@ -169,15 +176,6 @@ _ check with the a_Displaying example and tint(255, 0, 0, 100); _ Stroking a rect() leaves the upper right pixel off. -_ might be able to do a typed expand() -public Object growArray(Object array, int size) { - Class type = array.getClass().getComponentType(); - Object grown = Array.newInstance(type, size); - System.arraycopy(array, 0, grown, 0, - Math.min(Array.getLength(array), size)); - return grown; -} - _ beginShape() _ don't allow you to draw stroked items unless stroke() is called _ don't allow beginShape() if shape is already set