mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Changes to Dict and List classes for reference
This commit is contained in:
@@ -77,13 +77,21 @@ public class FloatDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/** Remove all entries. */
|
||||
/**
|
||||
* Remove all entries.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Remove all entries
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
@@ -112,7 +120,10 @@ public class FloatDict {
|
||||
// return keys;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public Iterable<String> keys() {
|
||||
return new Iterable<String>() {
|
||||
|
||||
@@ -169,6 +180,9 @@ public class FloatDict {
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Return a copy of the internal keys array
|
||||
*/
|
||||
public String[] keyArray() {
|
||||
return keyArray(null);
|
||||
@@ -194,7 +208,10 @@ public class FloatDict {
|
||||
// return values;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public Iterable<Float> values() {
|
||||
return new Iterable<Float>() {
|
||||
|
||||
@@ -222,6 +239,9 @@ public class FloatDict {
|
||||
|
||||
/**
|
||||
* Create a new array and copy each of the values into it.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Create a new array and copy each of the values into it
|
||||
*/
|
||||
public float[] valueArray() {
|
||||
return valueArray(null);
|
||||
@@ -244,6 +264,9 @@ public class FloatDict {
|
||||
|
||||
/**
|
||||
* Return a value for the specified key.
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Return a value for the specified key
|
||||
*/
|
||||
public float get(String key) {
|
||||
int index = index(key);
|
||||
@@ -252,6 +275,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void set(String key, int amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -262,6 +289,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return index(key) != -1;
|
||||
}
|
||||
@@ -279,6 +310,10 @@ public class FloatDict {
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void add(String key, float amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -295,11 +330,19 @@ public class FloatDict {
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sub(String key, float amount) {
|
||||
add(key, -amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void mult(String key, float amount) {
|
||||
int index = index(key);
|
||||
if (index != -1) {
|
||||
@@ -308,6 +351,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void div(String key, float amount) {
|
||||
int index = index(key);
|
||||
if (index != -1) {
|
||||
@@ -343,6 +390,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void remove(String key) {
|
||||
removeIndex(index(key));
|
||||
}
|
||||
@@ -391,6 +442,9 @@ public class FloatDict {
|
||||
/**
|
||||
* Sort the keys alphabetically (ignoring case). Uses the value as a
|
||||
* tie-breaker (only really possible with a key that has a case change).
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Sort the keys alphabetically
|
||||
*/
|
||||
public void sortKeys() {
|
||||
sortImpl(true, false);
|
||||
@@ -407,6 +461,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortKeysReverse() {
|
||||
sortImpl(true, true);
|
||||
// new InternalSort() {
|
||||
@@ -424,6 +482,9 @@ public class FloatDict {
|
||||
|
||||
/**
|
||||
* Sort by values in descending order (largest value will be at [0]).
|
||||
*
|
||||
* @webref floatdict:method
|
||||
* @brief Sort by values in descending order
|
||||
*/
|
||||
public void sortValues() {
|
||||
sortImpl(false, false);
|
||||
@@ -436,6 +497,10 @@ public class FloatDict {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortValuesReverse() {
|
||||
sortImpl(false, true);
|
||||
// new InternalSort() {
|
||||
|
||||
@@ -55,6 +55,9 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
/**
|
||||
* Get the length of the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Get the length of the list
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
@@ -76,6 +79,9 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
/**
|
||||
* Remove all entries from the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Remove all entries from the list
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
@@ -84,6 +90,9 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
/**
|
||||
* Get an entry at a particular index.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Get an entry at a particular index
|
||||
*/
|
||||
public float get(int index) {
|
||||
return data[index];
|
||||
@@ -94,6 +103,9 @@ public class FloatList implements Iterable<Float> {
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Set the entry at a particular index
|
||||
*/
|
||||
public void set(int index, float what) {
|
||||
if (index >= count) {
|
||||
@@ -107,7 +119,12 @@ public class FloatList implements Iterable<Float> {
|
||||
}
|
||||
|
||||
|
||||
/** remove an element from the specified index */
|
||||
/**
|
||||
* Remove an element from the specified index.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Remove an element from the specified index
|
||||
*/
|
||||
public void remove(int index) {
|
||||
// int[] outgoing = new int[count - 1];
|
||||
// System.arraycopy(data, 0, outgoing, 0, index);
|
||||
@@ -208,7 +225,12 @@ public class FloatList implements Iterable<Float> {
|
||||
|
||||
|
||||
|
||||
/** Add a new entry to the list. */
|
||||
/**
|
||||
* Add a new entry to the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Add a new entry to the list
|
||||
*/
|
||||
public void append(float value) {
|
||||
if (count == data.length) {
|
||||
data = PApplet.expand(data);
|
||||
@@ -367,7 +389,10 @@ public class FloatList implements Iterable<Float> {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasValue(float value) {
|
||||
if (Float.isNaN(value)) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -391,27 +416,42 @@ public class FloatList implements Iterable<Float> {
|
||||
// data[index]++;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void add(int index, float amount) {
|
||||
data[index] += amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sub(int index, float amount) {
|
||||
data[index] -= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void mult(int index, float amount) {
|
||||
data[index] *= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void div(int index, float amount) {
|
||||
data[index] /= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public float min() {
|
||||
if (count == 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("Cannot use min() on IntList of length 0.");
|
||||
@@ -438,7 +478,10 @@ public class FloatList implements Iterable<Float> {
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public float max() {
|
||||
if (count == 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("Cannot use max() on IntList of length 0.");
|
||||
@@ -466,13 +509,23 @@ public class FloatList implements Iterable<Float> {
|
||||
}
|
||||
|
||||
|
||||
/** Sorts the array in place. */
|
||||
/**
|
||||
* Sorts the array in place.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Sorts an array in place
|
||||
*/
|
||||
public void sort() {
|
||||
Arrays.sort(data, 0, count);
|
||||
}
|
||||
|
||||
|
||||
/** reverse sort, orders values from highest to lowest */
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortReverse() {
|
||||
new Sort() {
|
||||
@Override
|
||||
@@ -512,7 +565,10 @@ public class FloatList implements Iterable<Float> {
|
||||
count = num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void reverse() {
|
||||
int ii = count - 1;
|
||||
for (int i = 0; i < count/2; i++) {
|
||||
@@ -527,6 +583,9 @@ public class FloatList implements Iterable<Float> {
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Randomize the order of the list elements
|
||||
*/
|
||||
public void shuffle() {
|
||||
Random r = new Random();
|
||||
@@ -603,6 +662,8 @@ public class FloatList implements Iterable<Float> {
|
||||
/**
|
||||
* 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 floatlist:method
|
||||
* @brief Create a new array with a copy of all the values
|
||||
*/
|
||||
public int[] array() {
|
||||
return array(null);
|
||||
|
||||
@@ -100,13 +100,21 @@ public class IntDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/** Remove all entries. */
|
||||
/**
|
||||
* Remove all entries.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Remove all entries
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
@@ -129,6 +137,9 @@ public class IntDict {
|
||||
/**
|
||||
* Return the internal array being used to store the keys. Allocated but
|
||||
* unused entries will be removed. This array should not be modified.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Return the internal array being used to store the keys
|
||||
*/
|
||||
public String[] keys() {
|
||||
crop();
|
||||
@@ -164,6 +175,9 @@ public class IntDict {
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Return a copy of the internal keys array
|
||||
*/
|
||||
public String[] keyArray() {
|
||||
return keyArray(null);
|
||||
@@ -183,7 +197,10 @@ public class IntDict {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public Iterable<Integer> values() {
|
||||
return new Iterable<Integer>() {
|
||||
|
||||
@@ -211,6 +228,9 @@ public class IntDict {
|
||||
|
||||
/**
|
||||
* Create a new array and copy each of the values into it.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Create a new array and copy each of the values into it
|
||||
*/
|
||||
public int[] valueArray() {
|
||||
return valueArray(null);
|
||||
@@ -233,6 +253,9 @@ public class IntDict {
|
||||
|
||||
/**
|
||||
* Return a value for the specified key.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Return a value for the specified key
|
||||
*/
|
||||
public int get(String key) {
|
||||
int index = index(key);
|
||||
@@ -240,7 +263,10 @@ public class IntDict {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void set(String key, int amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -250,18 +276,29 @@ public class IntDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return index(key) != -1;
|
||||
}
|
||||
|
||||
|
||||
/** Increase the value of a specific key by 1. */
|
||||
/**
|
||||
* Increase the value of a specific key by 1.
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Increase the value of a specific key by 1
|
||||
*/
|
||||
public void increment(String key) {
|
||||
add(key, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void add(String key, int amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -271,12 +308,18 @@ public class IntDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sub(String key, int amount) {
|
||||
add(key, -amount);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void mult(String key, int amount) {
|
||||
int index = index(key);
|
||||
if (index != -1) {
|
||||
@@ -284,7 +327,10 @@ public class IntDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void div(String key, int amount) {
|
||||
int index = index(key);
|
||||
if (index != -1) {
|
||||
@@ -310,7 +356,10 @@ public class IntDict {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void remove(String key) {
|
||||
removeIndex(index(key));
|
||||
}
|
||||
@@ -346,12 +395,18 @@ public class IntDict {
|
||||
/**
|
||||
* Sort the keys alphabetically (ignoring case). Uses the value as a
|
||||
* tie-breaker (only really possible with a key that has a case change).
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Sort the keys alphabetically
|
||||
*/
|
||||
public void sortKeys() {
|
||||
sortImpl(true, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortKeysReverse() {
|
||||
sortImpl(true, true);
|
||||
}
|
||||
@@ -359,12 +414,18 @@ public class IntDict {
|
||||
|
||||
/**
|
||||
* Sort by values in descending order (largest value will be at [0]).
|
||||
*
|
||||
* @webref intdict:method
|
||||
* @brief Sort by values in descending order
|
||||
*/
|
||||
public void sortValues() {
|
||||
sortImpl(false, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref intdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortValuesReverse() {
|
||||
sortImpl(false, true);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import processing.core.PApplet;
|
||||
* Helper class for a list of ints. By design (for efficiency), functions like
|
||||
* sort() and shuffle() always act on the list itself. To get a sorted copy,
|
||||
* use list.copy().sort().
|
||||
*
|
||||
* @webref data:composite
|
||||
*/
|
||||
public class IntList implements Iterable<Integer> {
|
||||
@@ -63,6 +64,9 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
/**
|
||||
* Get the length of the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Get the length of the list
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
@@ -84,6 +88,9 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
/**
|
||||
* Remove all entries from the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Remove all entries from the list
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
@@ -92,6 +99,9 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
/**
|
||||
* Get an entry at a particular index.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Get an entry at a particular index
|
||||
*/
|
||||
public int get(int index) {
|
||||
return data[index];
|
||||
@@ -102,6 +112,9 @@ public class IntList implements Iterable<Integer> {
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Set the entry at a particular index
|
||||
*/
|
||||
public void set(int index, int what) {
|
||||
if (index >= count) {
|
||||
@@ -115,7 +128,12 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
|
||||
/** remove an element from the specified index */
|
||||
/**
|
||||
* Remove an element from the specified index
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Remove an element from the specified index
|
||||
*/
|
||||
public void remove(int index) {
|
||||
// int[] outgoing = new int[count - 1];
|
||||
// System.arraycopy(data, 0, outgoing, 0, index);
|
||||
@@ -154,7 +172,12 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
|
||||
/** Add a new entry to the list. */
|
||||
/**
|
||||
* Add a new entry to the list.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Add a new entry to the list
|
||||
*/
|
||||
public void append(int value) {
|
||||
if (count == data.length) {
|
||||
data = PApplet.expand(data);
|
||||
@@ -313,7 +336,10 @@ public class IntList implements Iterable<Integer> {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasValue(int value) {
|
||||
// if (indexCache == null) {
|
||||
// cacheIndices();
|
||||
@@ -327,32 +353,50 @@ public class IntList implements Iterable<Integer> {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void increment(int index) {
|
||||
data[index]++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void add(int index, int amount) {
|
||||
data[index] += amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sub(int index, int amount) {
|
||||
data[index] -= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void mult(int index, int amount) {
|
||||
data[index] *= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void div(int index, int amount) {
|
||||
data[index] /= amount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public int min() {
|
||||
if (count == 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("Cannot use min() on IntList of length 0.");
|
||||
@@ -364,7 +408,10 @@ public class IntList implements Iterable<Integer> {
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public int max() {
|
||||
if (count == 0) {
|
||||
throw new ArrayIndexOutOfBoundsException("Cannot use max() on IntList of length 0.");
|
||||
@@ -377,13 +424,23 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
|
||||
/** Sorts the array in place. */
|
||||
/**
|
||||
* Sorts the array in place.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Sorts the array in place
|
||||
*/
|
||||
public void sort() {
|
||||
Arrays.sort(data, 0, count);
|
||||
}
|
||||
|
||||
|
||||
/** reverse sort, orders values from highest to lowest */
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Reverse sort, orders values from highest to lowest
|
||||
*/
|
||||
public void sortReverse() {
|
||||
new Sort() {
|
||||
@Override
|
||||
@@ -423,7 +480,10 @@ public class IntList implements Iterable<Integer> {
|
||||
// count = num;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref floatlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void reverse() {
|
||||
int ii = count - 1;
|
||||
for (int i = 0; i < count/2; i++) {
|
||||
@@ -438,6 +498,9 @@ public class IntList implements Iterable<Integer> {
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
*
|
||||
* @webref floatlist:method
|
||||
* @brief Randomize the order of the list elements
|
||||
*/
|
||||
public void shuffle() {
|
||||
Random r = new Random();
|
||||
@@ -509,7 +572,10 @@ public class IntList implements Iterable<Integer> {
|
||||
|
||||
/**
|
||||
* 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 floatlist:method
|
||||
* @brief Create a new array with a copy of all the values
|
||||
*/
|
||||
public int[] array() {
|
||||
return array(null);
|
||||
|
||||
@@ -75,13 +75,21 @@ public class StringDict {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/** Remove all entries. */
|
||||
/**
|
||||
* Remove all entries.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Remove all entries
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
@@ -110,7 +118,10 @@ public class StringDict {
|
||||
// return keys;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public Iterable<String> keys() {
|
||||
return new Iterable<String>() {
|
||||
|
||||
@@ -138,6 +149,9 @@ public class StringDict {
|
||||
|
||||
/**
|
||||
* Return a copy of the internal keys array. This array can be modified.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Return a copy of the internal keys array
|
||||
*/
|
||||
public String[] keyArray() {
|
||||
return keyArray(null);
|
||||
@@ -157,7 +171,10 @@ public class StringDict {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public Iterable<String> values() {
|
||||
return new Iterable<String>() {
|
||||
|
||||
@@ -185,6 +202,9 @@ public class StringDict {
|
||||
|
||||
/**
|
||||
* Create a new array and copy each of the values into it.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Create a new array and copy each of the values into it
|
||||
*/
|
||||
public int[] valueArray() {
|
||||
return valueArray(null);
|
||||
@@ -207,6 +227,9 @@ public class StringDict {
|
||||
|
||||
/**
|
||||
* Return a value for the specified key.
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Return a value for the specified key
|
||||
*/
|
||||
public String get(String key) {
|
||||
int index = index(key);
|
||||
@@ -214,7 +237,10 @@ public class StringDict {
|
||||
return values[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void set(String key, String amount) {
|
||||
int index = index(key);
|
||||
if (index == -1) {
|
||||
@@ -230,7 +256,10 @@ public class StringDict {
|
||||
return (found == null) ? -1 : found.intValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return index(key) != -1;
|
||||
}
|
||||
@@ -247,7 +276,10 @@ public class StringDict {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void remove(String key) {
|
||||
removeIndex(index(key));
|
||||
}
|
||||
@@ -283,12 +315,18 @@ public class StringDict {
|
||||
/**
|
||||
* Sort the keys alphabetically (ignoring case). Uses the value as a
|
||||
* tie-breaker (only really possible with a key that has a case change).
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Sort the keys alphabetically
|
||||
*/
|
||||
public void sortKeys() {
|
||||
sortImpl(true, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortKeysReverse() {
|
||||
sortImpl(true, true);
|
||||
}
|
||||
@@ -296,12 +334,19 @@ public class StringDict {
|
||||
|
||||
/**
|
||||
* Sort by values in descending order (largest value will be at [0]).
|
||||
*
|
||||
* @webref stringdict:method
|
||||
* @brief Sort by values in descending order
|
||||
*/
|
||||
public void sortValues() {
|
||||
sortImpl(false, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringdict:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void sortValuesReverse() {
|
||||
sortImpl(false, true);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
/**
|
||||
* Get the length of the list.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Get the length of the list
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
@@ -77,6 +80,9 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
/**
|
||||
* Remove all entries from the list.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Remove all entries from the list
|
||||
*/
|
||||
public void clear() {
|
||||
count = 0;
|
||||
@@ -85,6 +91,9 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
/**
|
||||
* Get an entry at a particular index.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Get an entry at a particular index
|
||||
*/
|
||||
public String get(int index) {
|
||||
return data[index];
|
||||
@@ -95,6 +104,9 @@ public class StringList implements Iterable<String> {
|
||||
* Set the entry at a particular index. If the index is past the length of
|
||||
* the list, it'll expand the list to accommodate, and fill the intermediate
|
||||
* entries with 0s.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Set an entry at a particular index
|
||||
*/
|
||||
public void set(int index, String what) {
|
||||
if (index >= count) {
|
||||
@@ -108,7 +120,12 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** remove an element from the specified index */
|
||||
/**
|
||||
* Remove an element from the specified index.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Remove an element from the specified index
|
||||
*/
|
||||
public void remove(int index) {
|
||||
// int[] outgoing = new int[count - 1];
|
||||
// System.arraycopy(data, 0, outgoing, 0, index);
|
||||
@@ -205,7 +222,12 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** Add a new entry to the list. */
|
||||
/**
|
||||
* Add a new entry to the list.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Add a new entry to the list
|
||||
*/
|
||||
public void append(String value) {
|
||||
if (count == data.length) {
|
||||
data = PApplet.expand(data);
|
||||
@@ -363,7 +385,10 @@ public class StringList implements Iterable<String> {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public boolean hasValue(String value) {
|
||||
if (value == null) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -382,13 +407,23 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** Sorts the array in place. */
|
||||
/**
|
||||
* Sorts the array in place.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Sorts the array in place
|
||||
*/
|
||||
public void sort() {
|
||||
sortImpl(false);
|
||||
}
|
||||
|
||||
|
||||
/** reverse sort, orders values from highest to lowest */
|
||||
/**
|
||||
* Reverse sort, orders values from highest to lowest.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Reverse sort, orders values from highest to lowest
|
||||
*/
|
||||
public void sortReverse() {
|
||||
sortImpl(true);
|
||||
}
|
||||
@@ -434,7 +469,10 @@ public class StringList implements Iterable<String> {
|
||||
// count = num;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @webref stringlist:method
|
||||
* @brief To come...
|
||||
*/
|
||||
public void reverse() {
|
||||
int ii = count - 1;
|
||||
for (int i = 0; i < count/2; i++) {
|
||||
@@ -449,6 +487,9 @@ public class StringList implements Iterable<String> {
|
||||
/**
|
||||
* Randomize the order of the list elements. Note that this does not
|
||||
* obey the randomSeed() function in PApplet.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Randomize the order of the list elements
|
||||
*/
|
||||
public void shuffle() {
|
||||
Random r = new Random();
|
||||
@@ -479,7 +520,12 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** Make the entire list lower case. */
|
||||
/**
|
||||
* Make the entire list lower case.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Make the entire list lower case
|
||||
*/
|
||||
public void lower() {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (data[i] != null) {
|
||||
@@ -489,7 +535,12 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
/** Make the entire list upper case. */
|
||||
/**
|
||||
* Make the entire list upper case.
|
||||
*
|
||||
* @webref stringlist:method
|
||||
* @brief Make the entire list upper case
|
||||
*/
|
||||
public void upper() {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (data[i] != null) {
|
||||
@@ -544,7 +595,10 @@ public class StringList implements Iterable<String> {
|
||||
|
||||
/**
|
||||
* 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 stringlist:method
|
||||
* @brief Create a new array with a copy of all the values
|
||||
*/
|
||||
public String[] array() {
|
||||
return array(null);
|
||||
|
||||
+152
-2
@@ -413,9 +413,7 @@ createInput FUNCTION1 createInput_
|
||||
createOutput FUNCTION1 createOutput_
|
||||
createReader FUNCTION1 createReader_
|
||||
createShape FUNCTION1 createShape_
|
||||
loadTable FUNCTION1 createTable_
|
||||
createWriter FUNCTION1 createWriter_
|
||||
createXML FUNCTION1 createXML_
|
||||
cursor FUNCTION1 cursor_
|
||||
curve FUNCTION1 curve_
|
||||
curveDetail FUNCTION1 curveDetail_
|
||||
@@ -444,7 +442,43 @@ expand FUNCTION1 expand_
|
||||
fill FUNCTION1 fill_
|
||||
filter FUNCTION1 filter_
|
||||
FloatDict KEYWORD5 FloatDict
|
||||
add FUNCTION2 FloatDict_add_
|
||||
clear FUNCTION2 FloatDict_clear_
|
||||
div FUNCTION2 FloatDict_div_
|
||||
get FUNCTION2 FloatDict_get_
|
||||
hasKey FUNCTION2 FloatDict_hasKey_
|
||||
keyArray FUNCTION2 FloatDict_keyArray_
|
||||
keys FUNCTION2 FloatDict_keys_
|
||||
mult FUNCTION2 FloatDict_mult_
|
||||
remove FUNCTION2 FloatDict_remove_
|
||||
set FUNCTION2 FloatDict_set_
|
||||
size FUNCTION2 FloatDict_size_
|
||||
sortKeys FUNCTION2 FloatDict_sortKeys_
|
||||
sortKeysReverse FUNCTION2 FloatDict_sortKeysReverse_
|
||||
sortValues FUNCTION2 FloatDict_sortValues_
|
||||
sortValuesReverse FUNCTION2 FloatDict_sortValuesReverse_
|
||||
sub FUNCTION2 FloatDict_sub_
|
||||
valueArray FUNCTION2 FloatDict_valueArray_
|
||||
values FUNCTION2 FloatDict_values_
|
||||
FloatList KEYWORD5 FloatList
|
||||
add FUNCTION2 FloatList_add_
|
||||
append FUNCTION2 FloatList_append_
|
||||
array FUNCTION2 FloatList_array_
|
||||
clear FUNCTION2 FloatList_clear_
|
||||
div FUNCTION2 FloatList_div_
|
||||
get FUNCTION2 FloatList_get_
|
||||
hasValue FUNCTION2 FloatList_hasValue_
|
||||
max FUNCTION2 FloatList_max_
|
||||
min FUNCTION2 FloatList_min_
|
||||
mult FUNCTION2 FloatList_mult_
|
||||
remove FUNCTION2 FloatList_remove_
|
||||
reverse FUNCTION2 FloatList_reverse_
|
||||
set FUNCTION2 FloatList_set_
|
||||
shuffle FUNCTION2 FloatList_shuffle_
|
||||
size FUNCTION2 FloatList_size_
|
||||
sort FUNCTION2 FloatList_sort_
|
||||
sortReverse FUNCTION2 FloatList_sortReverse_
|
||||
sub FUNCTION2 FloatList_sub_
|
||||
floor FUNCTION1 floor_
|
||||
focused KEYWORD4 focused
|
||||
frameCount KEYWORD4 frameCount
|
||||
@@ -461,10 +495,77 @@ hue FUNCTION1 hue_
|
||||
image FUNCTION1 image_
|
||||
imageMode FUNCTION1 imageMode_
|
||||
IntDict KEYWORD5 IntDict
|
||||
add FUNCTION2 IntDict_add_
|
||||
clear FUNCTION2 IntDict_clear_
|
||||
div FUNCTION2 IntDict_div_
|
||||
get FUNCTION2 IntDict_get_
|
||||
hasKey FUNCTION2 IntDict_hasKey_
|
||||
increment FUNCTION2 IntDict_increment_
|
||||
keyArray FUNCTION2 IntDict_keyArray_
|
||||
keys FUNCTION2 IntDict_keys_
|
||||
mult FUNCTION2 IntDict_mult_
|
||||
remove FUNCTION2 IntDict_remove_
|
||||
set FUNCTION2 IntDict_set_
|
||||
size FUNCTION2 IntDict_size_
|
||||
sortKeys FUNCTION2 IntDict_sortKeys_
|
||||
sortKeysReverse FUNCTION2 IntDict_sortKeysReverse_
|
||||
sortValues FUNCTION2 IntDict_sortValues_
|
||||
sortValuesReverse FUNCTION2 IntDict_sortValuesReverse_
|
||||
sub FUNCTION2 IntDict_sub_
|
||||
valueArray FUNCTION2 IntDict_valueArray_
|
||||
values FUNCTION2 IntDict_values_
|
||||
IntList KEYWORD5 IntList
|
||||
add FUNCTION2 IntList_add_
|
||||
append FUNCTION2 IntList_append_
|
||||
array FUNCTION2 IntList_array_
|
||||
clear FUNCTION2 IntList_clear_
|
||||
div FUNCTION2 IntList_div_
|
||||
get FUNCTION2 IntList_get_
|
||||
hasValue FUNCTION2 IntList_hasValue_
|
||||
increment FUNCTION2 IntList_increment_
|
||||
max FUNCTION2 IntList_max_
|
||||
min FUNCTION2 IntList_min_
|
||||
mult FUNCTION2 IntList_mult_
|
||||
remove FUNCTION2 IntList_remove_
|
||||
reverse FUNCTION2 IntList_reverse_
|
||||
set FUNCTION2 IntList_set_
|
||||
shuffle FUNCTION2 IntList_shuffle_
|
||||
size FUNCTION2 IntList_size_
|
||||
sort FUNCTION2 IntList_sort_
|
||||
sortReverse FUNCTION2 IntList_sortReverse_
|
||||
sub FUNCTION2 IntList_sub_
|
||||
join FUNCTION1 join_
|
||||
JSONArray KEYWORD5 JSONArray
|
||||
append FUNCTION2 JSONArray_append_
|
||||
getBoolean FUNCTION2 JSONArray_getBoolean_
|
||||
getFloat FUNCTION2 JSONArray_getFloat_
|
||||
getInt FUNCTION2 JSONArray_getInt_
|
||||
getIntArray FUNCTION2 JSONArray_getIntArray_
|
||||
getJSONArray FUNCTION2 JSONArray_getJSONArray_
|
||||
getJSONObject FUNCTION2 JSONArray_getJSONObject_
|
||||
getString FUNCTION2 JSONArray_getString_
|
||||
getStringArray FUNCTION2 JSONArray_getStringArray_
|
||||
remove FUNCTION2 JSONArray_remove_
|
||||
setBoolean FUNCTION2 JSONArray_setBoolean_
|
||||
setFloat FUNCTION2 JSONArray_setFloat_
|
||||
setInt FUNCTION2 JSONArray_setInt_
|
||||
getJSONArray FUNCTION2 JSONArray_setJSONArray_
|
||||
getJSONObject FUNCTION2 JSONArray_setJSONObject_
|
||||
setString FUNCTION2 JSONArray_setString_
|
||||
size FUNCTION2 JSONArray_size_
|
||||
JSONObject KEYWORD5 JSONObject
|
||||
getBoolean FUNCTION2 JSONObject_getBoolean_
|
||||
getFloat FUNCTION2 JSONObject_getFloat_
|
||||
getInt FUNCTION2 JSONObject_getInt_
|
||||
getJSONArray FUNCTION2 JSONObject_getJSONArray_
|
||||
getJSONObject FUNCTION2 JSONObject_getJSONObject_
|
||||
getString FUNCTION2 JSONObject_getString_
|
||||
setBoolean FUNCTION2 JSONObject_setBoolean_
|
||||
setFloat FUNCTION2 JSONObject_setFloat_
|
||||
setInt FUNCTION2 JSONObject_setInt_
|
||||
getJSONArray FUNCTION2 JSONObject_setJSONArray_
|
||||
getJSONObject FUNCTION2 JSONObject_setJSONObject_
|
||||
setString FUNCTION2 JSONObject_setString_
|
||||
key KEYWORD4 key
|
||||
keyCode KEYWORD4 keyCode
|
||||
keyPressed FUNCTION4 keyPressed
|
||||
@@ -670,7 +771,35 @@ spotLight FUNCTION1 spotLight_
|
||||
sq FUNCTION1 sq_
|
||||
sqrt FUNCTION1 sqrt_
|
||||
StringDict KEYWORD5 StringDict
|
||||
clear FUNCTION2 StringDict_clear_
|
||||
get FUNCTION2 StringDict_get_
|
||||
hasKey FUNCTION2 StringDict_hasKey_
|
||||
keyArray FUNCTION2 StringDict_keyArray_
|
||||
keys FUNCTION2 StringDict_keys_
|
||||
remove FUNCTION2 StringDict_remove_
|
||||
set FUNCTION2 StringDict_set_
|
||||
size FUNCTION2 StringDict_size_
|
||||
sortKeys FUNCTION2 StringDict_sortKeys_
|
||||
sortKeysReverse FUNCTION2 StringDict_sortKeysReverse_
|
||||
sortValues FUNCTION2 StringDict_sortValues_
|
||||
sortValuesReverse FUNCTION2 StringDict_sortValuesReverse_
|
||||
valueArray FUNCTION2 StringDict_valueArray_
|
||||
values FUNCTION2 StringDict_values_
|
||||
StringList KEYWORD5 StringList
|
||||
append FUNCTION2 StringList_append_
|
||||
array FUNCTION2 StringList_array_
|
||||
clear FUNCTION2 StringList_clear_
|
||||
get FUNCTION2 StringList_get_
|
||||
hasValue FUNCTION2 StringList_hasValue_
|
||||
lower FUNCTION2 StringList_lower_
|
||||
remove FUNCTION2 StringList_remove_
|
||||
reverse FUNCTION2 StringList_reverse_
|
||||
set FUNCTION2 StringList_set_
|
||||
shuffle FUNCTION2 StringList_shuffle_
|
||||
size FUNCTION2 StringList_size_
|
||||
sort FUNCTION2 StringList_sort_
|
||||
sortReverse FUNCTION2 StringList_sortReverse_
|
||||
upper FUNCTION2 StringList_upper_
|
||||
stroke FUNCTION1 stroke_
|
||||
strokeCap FUNCTION1 strokeCap_
|
||||
strokeJoin FUNCTION1 strokeJoin_
|
||||
@@ -678,7 +807,28 @@ strokeWeight FUNCTION1 strokeWeight_
|
||||
subset FUNCTION1 subset_
|
||||
Table KEYWORD5 Table
|
||||
addColumn FUNCTION2 Table_addColumn_
|
||||
addRow FUNCTION2 Table_addRow_
|
||||
clearRows FUNCTION2 Table_clearRows_
|
||||
findRow FUNCTION2 Table_findRow_
|
||||
findRows FUNCTION2 Table_findRows_
|
||||
getColumnCount FUNCTION2 Table_getColumnCount_
|
||||
getRow FUNCTION2 Table_getRow_
|
||||
getRowCount FUNCTION2 Table_getRowCount_
|
||||
getStringColumn FUNCTION2 Table_getStringColumn_
|
||||
matchRow FUNCTION2 Table_matchRow_
|
||||
matchRows FUNCTION2 Table_matchRows_
|
||||
removeColumn FUNCTION2 Table_removeColumn_
|
||||
removeRow FUNCTION2 Table_removeRow_
|
||||
removeTokens FUNCTION2 Table_removeTokens_
|
||||
rows FUNCTION2 Table_rows_
|
||||
trim FUNCTION2 Table_trim_
|
||||
TableRow KEYWORD5 TableRow
|
||||
getFloat FUNCTION2 TableRow_getFloat_
|
||||
getFloat FUNCTION2 TableRow_getInt_
|
||||
getString FUNCTION2 TableRow_getString_
|
||||
setFloat FUNCTION2 TableRow_setFloat_
|
||||
setInt FUNCTION2 TableRow_setInt_
|
||||
setString FUNCTION2 TableRow_setString_
|
||||
tan FUNCTION1 tan_
|
||||
TAU LITERAL2 TAU
|
||||
text FUNCTION1 text_
|
||||
|
||||
Reference in New Issue
Block a user