tweaks for array functions and some notes

This commit is contained in:
benfry
2005-04-20 21:53:10 +00:00
parent e75191e5a3
commit f563e5ed89
2 changed files with 27 additions and 13 deletions

View File

@@ -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[],