propane 3.11.0-java → 4.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/CHANGELOG.md +2 -0
- data/README.md +5 -5
- data/Rakefile +1 -1
- data/lib/propane/app.rb +2 -2
- data/lib/propane/version.rb +1 -1
- data/lib/propane-4.0.0.jar +0 -0
- data/library/slider/slider.rb +1 -1
- data/pom.rb +8 -8
- data/pom.xml +8 -8
- data/propane.gemspec +3 -3
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PropaneLibrary.java +1 -1
- data/src/main/java/monkstone/fastmath/DegLutTables.java +10 -11
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/LICENSE +121 -0
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +92 -68
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +0 -1
- data/src/main/java/processing/awt/PImageAWT.java +2 -4
- data/src/main/java/processing/core/PApplet.java +4 -4
- data/src/main/java/processing/core/PImage.java +3025 -3047
- data/src/main/java/processing/core/PMatrix.java +5 -2
- data/src/main/java/processing/data/DoubleDict.java +72 -43
- data/src/main/java/processing/data/DoubleList.java +6 -2
- data/src/main/java/processing/data/FloatDict.java +744 -756
- data/src/main/java/processing/data/FloatList.java +68 -26
- data/src/main/java/processing/data/IntDict.java +72 -45
- data/src/main/java/processing/data/IntList.java +63 -26
- data/src/main/java/processing/data/JSONArray.java +892 -931
- data/src/main/java/processing/data/JSONObject.java +1169 -1262
- data/src/main/java/processing/data/JSONTokener.java +30 -49
- data/src/main/java/processing/data/LongDict.java +699 -712
- data/src/main/java/processing/data/LongList.java +676 -700
- data/src/main/java/processing/data/Sort.java +1 -0
- data/src/main/java/processing/data/Table.java +4040 -3661
- data/src/main/java/processing/data/TableRow.java +16 -0
- data/src/main/java/processing/data/XML.java +1041 -956
- data/src/main/java/processing/event/TouchEvent.java +1 -1
- data/src/main/java/processing/opengl/FontTexture.java +2 -2
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +15 -18
- data/src/main/java/processing/opengl/PJOGL.java +2 -2
- data/src/main/java/processing/opengl/PShapeOpenGL.java +23 -24
- data/test/vecmath_spec_test.rb +14 -3
- data/vendors/Rakefile +1 -1
- metadata +9 -8
- data/lib/propane-3.11.0.jar +0 -0
@@ -32,6 +32,7 @@ public class FloatList implements Iterable<Float> {
|
|
32
32
|
|
33
33
|
|
34
34
|
/**
|
35
|
+
* @param length
|
35
36
|
* @nowebref
|
36
37
|
*/
|
37
38
|
public FloatList(int length) {
|
@@ -40,6 +41,7 @@ public class FloatList implements Iterable<Float> {
|
|
40
41
|
|
41
42
|
|
42
43
|
/**
|
44
|
+
* @param list
|
43
45
|
* @nowebref
|
44
46
|
*/
|
45
47
|
public FloatList(float[] list) {
|
@@ -50,9 +52,9 @@ public class FloatList implements Iterable<Float> {
|
|
50
52
|
|
51
53
|
|
52
54
|
/**
|
53
|
-
* Construct an FloatList from an iterable pile of objects.
|
54
|
-
* For instance, a float array, an array of strings, who knows).
|
55
|
+
* Construct an FloatList from an iterable pile of objects.For instance, a float array, an array of strings, who knows).
|
55
56
|
* Un-parseable or null values will be set to NaN.
|
57
|
+
* @param iter
|
56
58
|
* @nowebref
|
57
59
|
*/
|
58
60
|
public FloatList(Iterable<Object> iter) {
|
@@ -71,8 +73,8 @@ public class FloatList implements Iterable<Float> {
|
|
71
73
|
|
72
74
|
|
73
75
|
/**
|
74
|
-
* Construct an FloatList from a random pile of objects.
|
75
|
-
*
|
76
|
+
* Construct an FloatList from a random pile of objects.Un-parseable or null values will be set to NaN.
|
77
|
+
* @param items
|
76
78
|
*/
|
77
79
|
public FloatList(Object... items) {
|
78
80
|
// nuts, no good way to pass missingValue to this fn (varargs must be last)
|
@@ -84,8 +86,8 @@ public class FloatList implements Iterable<Float> {
|
|
84
86
|
for (Object o : items) {
|
85
87
|
float value = missingValue;
|
86
88
|
if (o != null) {
|
87
|
-
if (o instanceof Number) {
|
88
|
-
value =
|
89
|
+
if (o instanceof Number number) {
|
90
|
+
value = number.floatValue();
|
89
91
|
} else {
|
90
92
|
value = PApplet.parseFloat(o.toString().trim(), missingValue);
|
91
93
|
}
|
@@ -111,6 +113,7 @@ public class FloatList implements Iterable<Float> {
|
|
111
113
|
/**
|
112
114
|
* Get the length of the list.
|
113
115
|
*
|
116
|
+
* @return
|
114
117
|
* @webref floatlist:method
|
115
118
|
* @brief Get the length of the list
|
116
119
|
*/
|
@@ -146,6 +149,8 @@ public class FloatList implements Iterable<Float> {
|
|
146
149
|
/**
|
147
150
|
* Get an entry at a particular index.
|
148
151
|
*
|
152
|
+
* @param index
|
153
|
+
* @return
|
149
154
|
* @webref floatlist:method
|
150
155
|
* @brief Get an entry at a particular index
|
151
156
|
*/
|
@@ -158,10 +163,12 @@ public class FloatList implements Iterable<Float> {
|
|
158
163
|
|
159
164
|
|
160
165
|
/**
|
161
|
-
* Set the entry at a particular index.
|
162
|
-
|
163
|
-
|
166
|
+
* Set the entry at a particular index.If the index is past the length of
|
167
|
+
the list, it'll expand the list to accommodate, and fill the intermediate
|
168
|
+
entries with 0s.
|
164
169
|
*
|
170
|
+
* @param index
|
171
|
+
* @param what
|
165
172
|
* @webref floatlist:method
|
166
173
|
* @brief Set the entry at a particular index
|
167
174
|
*/
|
@@ -177,7 +184,8 @@ public class FloatList implements Iterable<Float> {
|
|
177
184
|
}
|
178
185
|
|
179
186
|
|
180
|
-
/** Just an alias for append(), but matches pop()
|
187
|
+
/** Just an alias for append(), but matches pop()
|
188
|
+
* @param value */
|
181
189
|
public void push(float value) {
|
182
190
|
append(value);
|
183
191
|
}
|
@@ -196,6 +204,8 @@ public class FloatList implements Iterable<Float> {
|
|
196
204
|
/**
|
197
205
|
* Remove an element from the specified index.
|
198
206
|
*
|
207
|
+
* @param index
|
208
|
+
* @return
|
199
209
|
* @webref floatlist:method
|
200
210
|
* @brief Remove an element from the specified index
|
201
211
|
*/
|
@@ -254,7 +264,10 @@ public class FloatList implements Iterable<Float> {
|
|
254
264
|
}
|
255
265
|
|
256
266
|
|
257
|
-
/** Replace the first instance of a particular value
|
267
|
+
/** Replace the first instance of a particular value
|
268
|
+
* @param value
|
269
|
+
* @param newValue
|
270
|
+
* @return */
|
258
271
|
public boolean replaceValue(float value, float newValue) {
|
259
272
|
if (Float.isNaN(value)) {
|
260
273
|
for (int i = 0; i < count; i++) {
|
@@ -274,7 +287,10 @@ public class FloatList implements Iterable<Float> {
|
|
274
287
|
}
|
275
288
|
|
276
289
|
|
277
|
-
/** Replace all instances of a particular value
|
290
|
+
/** Replace all instances of a particular value
|
291
|
+
* @param value
|
292
|
+
* @param newValue
|
293
|
+
* @return */
|
278
294
|
public boolean replaceValues(float value, float newValue) {
|
279
295
|
boolean changed = false;
|
280
296
|
if (Float.isNaN(value)) {
|
@@ -300,6 +316,7 @@ public class FloatList implements Iterable<Float> {
|
|
300
316
|
/**
|
301
317
|
* Add a new entry to the list.
|
302
318
|
*
|
319
|
+
* @param value
|
303
320
|
* @webref floatlist:method
|
304
321
|
* @brief Add a new entry to the list
|
305
322
|
*/
|
@@ -325,7 +342,8 @@ public class FloatList implements Iterable<Float> {
|
|
325
342
|
}
|
326
343
|
|
327
344
|
|
328
|
-
/** Add this value, but only if it's not already in the list.
|
345
|
+
/** Add this value, but only if it's not already in the list.
|
346
|
+
* @param value */
|
329
347
|
public void appendUnique(float value) {
|
330
348
|
if (!hasValue(value)) {
|
331
349
|
append(value);
|
@@ -445,7 +463,9 @@ public class FloatList implements Iterable<Float> {
|
|
445
463
|
// }
|
446
464
|
|
447
465
|
|
448
|
-
/** Return the first index of a particular value.
|
466
|
+
/** Return the first index of a particular value.
|
467
|
+
* @param what
|
468
|
+
* @return */
|
449
469
|
public int index(float what) {
|
450
470
|
/*
|
451
471
|
if (indexCache != null) {
|
@@ -466,6 +486,8 @@ public class FloatList implements Iterable<Float> {
|
|
466
486
|
|
467
487
|
|
468
488
|
/**
|
489
|
+
* @param value
|
490
|
+
* @return
|
469
491
|
* @webref floatlist:method
|
470
492
|
* @brief Check if a number is a part of the list
|
471
493
|
*/
|
@@ -495,6 +517,8 @@ public class FloatList implements Iterable<Float> {
|
|
495
517
|
|
496
518
|
|
497
519
|
/**
|
520
|
+
* @param index
|
521
|
+
* @param amount
|
498
522
|
* @webref floatlist:method
|
499
523
|
* @brief Add to a value
|
500
524
|
*/
|
@@ -508,6 +532,8 @@ public class FloatList implements Iterable<Float> {
|
|
508
532
|
|
509
533
|
|
510
534
|
/**
|
535
|
+
* @param index
|
536
|
+
* @param amount
|
511
537
|
* @webref floatlist:method
|
512
538
|
* @brief Subtract from a value
|
513
539
|
*/
|
@@ -521,6 +547,8 @@ public class FloatList implements Iterable<Float> {
|
|
521
547
|
|
522
548
|
|
523
549
|
/**
|
550
|
+
* @param index
|
551
|
+
* @param amount
|
524
552
|
* @webref floatlist:method
|
525
553
|
* @brief Multiply a value
|
526
554
|
*/
|
@@ -534,6 +562,8 @@ public class FloatList implements Iterable<Float> {
|
|
534
562
|
|
535
563
|
|
536
564
|
/**
|
565
|
+
* @param index
|
566
|
+
* @param amount
|
537
567
|
* @webref floatlist:method
|
538
568
|
* @brief Divide a value
|
539
569
|
*/
|
@@ -557,6 +587,7 @@ public class FloatList implements Iterable<Float> {
|
|
557
587
|
|
558
588
|
|
559
589
|
/**
|
590
|
+
* @return
|
560
591
|
* @webref floatlist:method
|
561
592
|
* @brief Return the smallest value
|
562
593
|
*/
|
@@ -593,6 +624,7 @@ public class FloatList implements Iterable<Float> {
|
|
593
624
|
|
594
625
|
|
595
626
|
/**
|
627
|
+
* @return
|
596
628
|
* @webref floatlist:method
|
597
629
|
* @brief Return the largest value
|
598
630
|
*/
|
@@ -765,6 +797,7 @@ public class FloatList implements Iterable<Float> {
|
|
765
797
|
/**
|
766
798
|
* Randomize the list order using the random() function from the specified
|
767
799
|
* sketch, allowing shuffle() to use its current randomSeed() setting.
|
800
|
+
* @param sketch
|
768
801
|
*/
|
769
802
|
public void shuffle(PApplet sketch) {
|
770
803
|
int num = count;
|
@@ -786,9 +819,10 @@ public class FloatList implements Iterable<Float> {
|
|
786
819
|
|
787
820
|
|
788
821
|
/**
|
789
|
-
* Returns the actual array being used to store the data.
|
790
|
-
|
791
|
-
|
822
|
+
* Returns the actual array being used to store the data.For advanced users,
|
823
|
+
this is the fastest way to access a large list. Suitable for iterating
|
824
|
+
with a for() loop, but modifying the list will have terrible consequences.
|
825
|
+
* @return
|
792
826
|
*/
|
793
827
|
public float[] values() {
|
794
828
|
crop();
|
@@ -806,15 +840,18 @@ public class FloatList implements Iterable<Float> {
|
|
806
840
|
return new Iterator<Float>() {
|
807
841
|
int index = -1;
|
808
842
|
|
843
|
+
@Override
|
809
844
|
public void remove() {
|
810
845
|
FloatList.this.remove(index);
|
811
846
|
index--;
|
812
847
|
}
|
813
848
|
|
849
|
+
@Override
|
814
850
|
public Float next() {
|
815
851
|
return data[++index];
|
816
852
|
}
|
817
853
|
|
854
|
+
@Override
|
818
855
|
public boolean hasNext() {
|
819
856
|
return index+1 < count;
|
820
857
|
}
|
@@ -834,9 +871,10 @@ public class FloatList implements Iterable<Float> {
|
|
834
871
|
|
835
872
|
|
836
873
|
/**
|
837
|
-
* Copy values into the specified array.
|
838
|
-
|
874
|
+
* Copy values into the specified array.If the specified array is null or
|
875
|
+
not the same size, a new array will be allocated.
|
839
876
|
* @param array
|
877
|
+
* @return
|
840
878
|
*/
|
841
879
|
public float[] array(float[] array) {
|
842
880
|
if (array == null || array.length != count) {
|
@@ -848,10 +886,11 @@ public class FloatList implements Iterable<Float> {
|
|
848
886
|
|
849
887
|
|
850
888
|
/**
|
851
|
-
* Returns a normalized version of this array.
|
852
|
-
|
853
|
-
|
854
|
-
|
889
|
+
* Returns a normalized version of this array.Called getPercent() for
|
890
|
+
consistency with the Dict classes. It's a getter method because it needs
|
891
|
+
to returns a new list (because IntList/Dict can't do percentages or
|
892
|
+
normalization in place on int values).
|
893
|
+
* @return
|
855
894
|
*/
|
856
895
|
public FloatList getPercent() {
|
857
896
|
double sum = 0;
|
@@ -902,16 +941,18 @@ public class FloatList implements Iterable<Float> {
|
|
902
941
|
|
903
942
|
/**
|
904
943
|
* Save tab-delimited entries to a file (TSV format, UTF-8 encoding)
|
944
|
+
* @param file
|
905
945
|
*/
|
906
946
|
public void save(File file) {
|
907
|
-
|
908
|
-
|
909
|
-
|
947
|
+
try (PrintWriter writer = PApplet.createWriter(file)) {
|
948
|
+
write(writer);
|
949
|
+
}
|
910
950
|
}
|
911
951
|
|
912
952
|
|
913
953
|
/**
|
914
954
|
* Write entries to a PrintWriter, one per line
|
955
|
+
* @param writer
|
915
956
|
*/
|
916
957
|
public void write(PrintWriter writer) {
|
917
958
|
for (int i = 0; i < count; i++) {
|
@@ -923,6 +964,7 @@ public class FloatList implements Iterable<Float> {
|
|
923
964
|
|
924
965
|
/**
|
925
966
|
* Return this dictionary as a String in JSON format.
|
967
|
+
* @return
|
926
968
|
*/
|
927
969
|
public String toJSON() {
|
928
970
|
return "[ " + join(", ") + " ]";
|
@@ -35,9 +35,11 @@ public class IntDict {
|
|
35
35
|
|
36
36
|
|
37
37
|
/**
|
38
|
-
* Create a new lookup with a specific size.
|
39
|
-
* specifying a size. Use it when you know the rough size of the thing you're
|
38
|
+
* Create a new lookup with a specific size.This is more efficient than not
|
39
|
+
* specifying a size. Use it when you know the rough size of the thing you're
|
40
|
+
* creating.
|
40
41
|
*
|
42
|
+
* @param length
|
41
43
|
* @nowebref
|
42
44
|
*/
|
43
45
|
public IntDict(int length) {
|
@@ -51,6 +53,7 @@ public class IntDict {
|
|
51
53
|
* Read a set of entries from a Reader that has each key/value pair on
|
52
54
|
* a single line, separated by a tab.
|
53
55
|
*
|
56
|
+
* @param reader
|
54
57
|
* @nowebref
|
55
58
|
*/
|
56
59
|
public IntDict(BufferedReader reader) {
|
@@ -58,18 +61,20 @@ public class IntDict {
|
|
58
61
|
keys = new String[lines.length];
|
59
62
|
values = new int[lines.length];
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
for (String line : lines) {
|
65
|
+
String[] pieces = PApplet.split(line, '\t');
|
66
|
+
if (pieces.length == 2) {
|
67
|
+
keys[count] = pieces[0];
|
68
|
+
values[count] = PApplet.parseInt(pieces[1]);
|
69
|
+
indices.put(pieces[0], count);
|
70
|
+
count++;
|
71
|
+
}
|
68
72
|
}
|
69
|
-
}
|
70
73
|
}
|
71
74
|
|
72
75
|
/**
|
76
|
+
* @param keys
|
77
|
+
* @param values
|
73
78
|
* @nowebref
|
74
79
|
*/
|
75
80
|
public IntDict(String[] keys, int[] values) {
|
@@ -93,6 +98,7 @@ public class IntDict {
|
|
93
98
|
* { "key2", 2 }
|
94
99
|
* });
|
95
100
|
* </pre>
|
101
|
+
* @param pairs
|
96
102
|
*/
|
97
103
|
public IntDict(Object[][] pairs) {
|
98
104
|
count = pairs.length;
|
@@ -109,6 +115,7 @@ public class IntDict {
|
|
109
115
|
/**
|
110
116
|
* Returns the number of key/value pairs
|
111
117
|
*
|
118
|
+
* @return
|
112
119
|
* @webref intdict:method
|
113
120
|
* @brief Returns the number of key/value pairs
|
114
121
|
*/
|
@@ -118,8 +125,8 @@ public class IntDict {
|
|
118
125
|
|
119
126
|
|
120
127
|
/**
|
121
|
-
* Resize the internal data, this can only be used to shrink the list.
|
122
|
-
*
|
128
|
+
* Resize the internal data, this can only be used to shrink the list.Helpful for situations like sorting and then grabbing the top 50 entries.
|
129
|
+
* @param length
|
123
130
|
*/
|
124
131
|
public void resize(int length) {
|
125
132
|
if (length > count) {
|
@@ -175,12 +182,7 @@ public class IntDict {
|
|
175
182
|
|
176
183
|
|
177
184
|
public Iterable<Entry> entries() {
|
178
|
-
return
|
179
|
-
|
180
|
-
public Iterator<Entry> iterator() {
|
181
|
-
return entryIterator();
|
182
|
-
}
|
183
|
-
};
|
185
|
+
return () -> entryIterator();
|
184
186
|
}
|
185
187
|
|
186
188
|
|
@@ -188,17 +190,20 @@ public class IntDict {
|
|
188
190
|
return new Iterator<Entry>() {
|
189
191
|
int index = -1;
|
190
192
|
|
193
|
+
@Override
|
191
194
|
public void remove() {
|
192
195
|
removeIndex(index);
|
193
196
|
index--;
|
194
197
|
}
|
195
198
|
|
199
|
+
@Override
|
196
200
|
public Entry next() {
|
197
201
|
++index;
|
198
202
|
Entry e = new Entry(keys[index], values[index]);
|
199
203
|
return e;
|
200
204
|
}
|
201
205
|
|
206
|
+
@Override
|
202
207
|
public boolean hasNext() {
|
203
208
|
return index+1 < size();
|
204
209
|
}
|
@@ -223,13 +228,7 @@ public class IntDict {
|
|
223
228
|
|
224
229
|
|
225
230
|
public Iterable<String> keys() {
|
226
|
-
return
|
227
|
-
|
228
|
-
@Override
|
229
|
-
public Iterator<String> iterator() {
|
230
|
-
return keyIterator();
|
231
|
-
}
|
232
|
-
};
|
231
|
+
return () -> keyIterator();
|
233
232
|
}
|
234
233
|
|
235
234
|
|
@@ -238,15 +237,18 @@ public class IntDict {
|
|
238
237
|
return new Iterator<String>() {
|
239
238
|
int index = -1;
|
240
239
|
|
240
|
+
@Override
|
241
241
|
public void remove() {
|
242
242
|
removeIndex(index);
|
243
243
|
index--;
|
244
244
|
}
|
245
245
|
|
246
|
+
@Override
|
246
247
|
public String next() {
|
247
248
|
return key(++index);
|
248
249
|
}
|
249
250
|
|
251
|
+
@Override
|
250
252
|
public boolean hasNext() {
|
251
253
|
return index+1 < size();
|
252
254
|
}
|
@@ -255,8 +257,9 @@ public class IntDict {
|
|
255
257
|
|
256
258
|
|
257
259
|
/**
|
258
|
-
* Return a copy of the internal keys array.
|
260
|
+
* Return a copy of the internal keys array.This array can be modified.
|
259
261
|
*
|
262
|
+
* @return
|
260
263
|
* @webref intdict:method
|
261
264
|
* @brief Return a copy of the internal keys array
|
262
265
|
*/
|
@@ -281,17 +284,12 @@ public class IntDict {
|
|
281
284
|
|
282
285
|
|
283
286
|
/**
|
287
|
+
* @return
|
284
288
|
* @webref intdict:method
|
285
289
|
* @brief Return the internal array being used to store the values
|
286
290
|
*/
|
287
291
|
public Iterable<Integer> values() {
|
288
|
-
return
|
289
|
-
|
290
|
-
@Override
|
291
|
-
public Iterator<Integer> iterator() {
|
292
|
-
return valueIterator();
|
293
|
-
}
|
294
|
-
};
|
292
|
+
return () -> valueIterator();
|
295
293
|
}
|
296
294
|
|
297
295
|
|
@@ -299,15 +297,18 @@ public class IntDict {
|
|
299
297
|
return new Iterator<Integer>() {
|
300
298
|
int index = -1;
|
301
299
|
|
300
|
+
@Override
|
302
301
|
public void remove() {
|
303
302
|
removeIndex(index);
|
304
303
|
index--;
|
305
304
|
}
|
306
305
|
|
306
|
+
@Override
|
307
307
|
public Integer next() {
|
308
308
|
return value(++index);
|
309
309
|
}
|
310
310
|
|
311
|
+
@Override
|
311
312
|
public boolean hasNext() {
|
312
313
|
return index+1 < size();
|
313
314
|
}
|
@@ -318,6 +319,7 @@ public class IntDict {
|
|
318
319
|
/**
|
319
320
|
* Create a new array and copy each of the values into it.
|
320
321
|
*
|
322
|
+
* @return
|
321
323
|
* @webref intdict:method
|
322
324
|
* @brief Create a new array and copy each of the values into it
|
323
325
|
*/
|
@@ -329,10 +331,12 @@ public class IntDict {
|
|
329
331
|
|
330
332
|
/**
|
331
333
|
* Fill an already-allocated array with the values (more efficient than
|
332
|
-
* creating a new array each time).
|
333
|
-
|
334
|
+
* creating a new array each time).If 'array' is null, or not the same
|
335
|
+
size as the number of values, a new array will be allocated and returned.
|
334
336
|
*
|
335
337
|
* @param array values to copy into the array
|
338
|
+
|
339
|
+
* @return
|
336
340
|
*/
|
337
341
|
public int[] valueArray(int[] array) {
|
338
342
|
if (array == null || array.length != size()) {
|
@@ -346,6 +350,8 @@ public class IntDict {
|
|
346
350
|
/**
|
347
351
|
* Return a value for the specified key.
|
348
352
|
*
|
353
|
+
* @param key
|
354
|
+
* @return
|
349
355
|
* @webref intdict:method
|
350
356
|
* @brief Return a value for the specified key
|
351
357
|
*/
|
@@ -368,6 +374,8 @@ public class IntDict {
|
|
368
374
|
/**
|
369
375
|
* Create a new key/value pair or change the value of one.
|
370
376
|
*
|
377
|
+
* @param key
|
378
|
+
* @param amount
|
371
379
|
* @webref intdict:method
|
372
380
|
* @brief Create a new key/value pair or change the value of one
|
373
381
|
*/
|
@@ -391,6 +399,8 @@ public class IntDict {
|
|
391
399
|
|
392
400
|
|
393
401
|
/**
|
402
|
+
* @param key
|
403
|
+
* @return
|
394
404
|
* @webref intdict:method
|
395
405
|
* @brief Check if a key is a part of the data structure
|
396
406
|
*/
|
@@ -402,6 +412,7 @@ public class IntDict {
|
|
402
412
|
/**
|
403
413
|
* Increase the value associated with a specific key by 1.
|
404
414
|
*
|
415
|
+
* @param key
|
405
416
|
* @webref intdict:method
|
406
417
|
* @brief Increase the value of a specific key value by 1
|
407
418
|
*/
|
@@ -411,9 +422,10 @@ public class IntDict {
|
|
411
422
|
|
412
423
|
|
413
424
|
/**
|
414
|
-
* Merge another dictionary into this one.
|
415
|
-
|
416
|
-
|
425
|
+
* Merge another dictionary into this one.Calling this increment()
|
426
|
+
since it doesn't make sense in practice for the other dictionary types,
|
427
|
+
even though it's technically an add().
|
428
|
+
* @param dict
|
417
429
|
*/
|
418
430
|
public void increment(IntDict dict) {
|
419
431
|
for (int i = 0; i < dict.count; i++) {
|
@@ -423,6 +435,8 @@ public class IntDict {
|
|
423
435
|
|
424
436
|
|
425
437
|
/**
|
438
|
+
* @param key
|
439
|
+
* @param amount
|
426
440
|
* @webref intdict:method
|
427
441
|
* @brief Add to a value
|
428
442
|
*/
|
@@ -437,6 +451,8 @@ public class IntDict {
|
|
437
451
|
|
438
452
|
|
439
453
|
/**
|
454
|
+
* @param key
|
455
|
+
* @param amount
|
440
456
|
* @webref intdict:method
|
441
457
|
* @brief Subtract from a value
|
442
458
|
*/
|
@@ -446,6 +462,8 @@ public class IntDict {
|
|
446
462
|
|
447
463
|
|
448
464
|
/**
|
465
|
+
* @param key
|
466
|
+
* @param amount
|
449
467
|
* @webref intdict:method
|
450
468
|
* @brief Multiply a value
|
451
469
|
*/
|
@@ -458,6 +476,8 @@ public class IntDict {
|
|
458
476
|
|
459
477
|
|
460
478
|
/**
|
479
|
+
* @param key
|
480
|
+
* @param amount
|
461
481
|
* @webref intdict:method
|
462
482
|
* @brief Divide a value
|
463
483
|
*/
|
@@ -532,7 +552,8 @@ public class IntDict {
|
|
532
552
|
}
|
533
553
|
|
534
554
|
|
535
|
-
/** return the key corresponding to the maximum value or null if no entries
|
555
|
+
/** return the key corresponding to the maximum value or null if no entries
|
556
|
+
* @return */
|
536
557
|
public String maxKey() {
|
537
558
|
//checkMinMax("maxKey");
|
538
559
|
int index = maxIndex();
|
@@ -573,7 +594,7 @@ public class IntDict {
|
|
573
594
|
|
574
595
|
public int index(String what) {
|
575
596
|
Integer found = indices.get(what);
|
576
|
-
return (found == null) ? -1 : found
|
597
|
+
return (found == null) ? -1 : found;
|
577
598
|
}
|
578
599
|
|
579
600
|
|
@@ -582,13 +603,15 @@ public class IntDict {
|
|
582
603
|
keys = PApplet.expand(keys);
|
583
604
|
values = PApplet.expand(values);
|
584
605
|
}
|
585
|
-
indices.put(what,
|
606
|
+
indices.put(what, count);
|
586
607
|
keys[count] = what;
|
587
608
|
values[count] = much;
|
588
609
|
count++;
|
589
610
|
}
|
590
611
|
|
591
612
|
/**
|
613
|
+
* @param key
|
614
|
+
* @return
|
592
615
|
* @webref intdict:method
|
593
616
|
* @brief Remove a key/value pair
|
594
617
|
*/
|
@@ -747,7 +770,8 @@ public class IntDict {
|
|
747
770
|
}
|
748
771
|
|
749
772
|
|
750
|
-
/** Returns a duplicate copy of this object.
|
773
|
+
/** Returns a duplicate copy of this object.
|
774
|
+
* @return */
|
751
775
|
public IntDict copy() {
|
752
776
|
IntDict outgoing = new IntDict(count);
|
753
777
|
System.arraycopy(keys, 0, outgoing.keys, 0, count);
|
@@ -769,16 +793,18 @@ public class IntDict {
|
|
769
793
|
|
770
794
|
/**
|
771
795
|
* Save tab-delimited entries to a file (TSV format, UTF-8 encoding)
|
796
|
+
* @param file
|
772
797
|
*/
|
773
798
|
public void save(File file) {
|
774
|
-
|
775
|
-
|
776
|
-
|
799
|
+
try (PrintWriter writer = PApplet.createWriter(file)) {
|
800
|
+
write(writer);
|
801
|
+
}
|
777
802
|
}
|
778
803
|
|
779
804
|
|
780
805
|
/**
|
781
806
|
* Write tab-delimited entries to a PrintWriter
|
807
|
+
* @param writer
|
782
808
|
*/
|
783
809
|
public void write(PrintWriter writer) {
|
784
810
|
for (int i = 0; i < count; i++) {
|
@@ -790,6 +816,7 @@ public class IntDict {
|
|
790
816
|
|
791
817
|
/**
|
792
818
|
* Return this dictionary as a String in JSON format.
|
819
|
+
* @return
|
793
820
|
*/
|
794
821
|
public String toJSON() {
|
795
822
|
StringList items = new StringList();
|