mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
tweaks for array functions and some notes
This commit is contained in:
@@ -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[],
|
||||
|
||||
Reference in New Issue
Block a user