/** * Create a new array with a copy of all the values. * * @return an array sized by the length of the list with each of the values. * @webref intlist:method * @brief Create a new array with a copy of all the values */ public int[] array() { return array(null); }
public int maxIndex() { checkMinMax("maxIndex"); int value = data[0]; int index = 0; for (int i = 1; i < count; i++) { if (data[i] > value) { value = data[i]; index = i; } } return index; }
public IntList copy() { IntList outgoing = new IntList(data); outgoing.count = count; return outgoing; }
/** * Construct an IntList from an iterable pile of objects. * For instance, a float array, an array of strings, who knows). * Un-parseable or null values will be set to 0. * @nowebref */ public IntList(Iterable<Object> iter) { this(10); for (Object o : iter) { if (o == null) { append(0); // missing value default } else if (o instanceof Number) { append(((Number) o).intValue()); } else { append(PApplet.parseInt(o.toString().trim())); } } crop(); }
public void append(int[] values) { for (int v : values) { append(v); } }
static public IntList fromRange(int stop) { return fromRange(0, stop); }
public void remove() { IntList.this.remove(index); index--; }
/** * Returns the actual array being used to store the data. For advanced users, * this is the fastest way to access a large list. Suitable for iterating * with a for() loop, but modifying the list will have terrible consequences. */ public int[] values() { crop(); return data; }
public IntList getSubset(int start) { return getSubset(start, count - start); }
public void insert(int index, int value) { insert(index, new int[] { value }); }
public int maxIndex() { checkMinMax("maxIndex"); int value = data[0]; int index = 0; for (int i = 1; i < count; i++) { if (data[i] > value) { value = data[i]; index = i; } } return index; }
public IntList copy() { IntList outgoing = new IntList(data); outgoing.count = count; return outgoing; }