picrate 0.5.0-java → 0.6.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/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +3 -1
- data/README.md +1 -1
- data/Rakefile +8 -6
- data/docs/_editors/geany.md +5 -4
- data/docs/_editors/vim.md +6 -0
- data/docs/_includes/head.html +1 -0
- data/docs/_libraries/control_panel.md +2 -2
- data/docs/_libraries/gl_video.md +21 -0
- data/docs/_posts/2018-05-06-getting_started.md +10 -9
- data/docs/_posts/2018-05-06-install_jruby.md +19 -2
- data/docs/_posts/2018-06-26-auto_install_picrate.md +19 -4
- data/docs/_posts/2018-11-18-building-gem.md +18 -0
- data/docs/_posts/2018-11-27-getting_started_geany.md +38 -0
- data/docs/about.md +21 -10
- data/docs/assets/android-chrome-192x192.png +0 -0
- data/docs/assets/android-chrome-512x512.png +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/geany.png +0 -0
- data/docs/assets/jwishy_picrate.png +0 -0
- data/docs/assets/picrate.svg +251 -0
- data/docs/index.html +8 -14
- data/lib/picrate/runner.rb +6 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +10 -13
- data/mvnw +234 -0
- data/picrate.gemspec +2 -1
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +10 -2
- data/src/main/java/monkstone/ColorUtil.java +11 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -0
- data/src/main/java/monkstone/PicrateLibrary.java +1 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -0
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- 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/SimpleSlider.java +8 -8
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/Slider.java +3 -3
- 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/vecmath/AppRender.java +1 -0
- data/src/main/java/monkstone/vecmath/JRender.java +1 -0
- data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -0
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -0
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +85 -16
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +18 -12
- data/src/main/java/processing/core/PShape.java +1182 -305
- data/src/main/java/processing/core/PStyle.java +1 -1
- data/src/main/java/processing/core/PSurface.java +1 -1
- data/src/main/java/processing/data/FloatDict.java +196 -54
- data/src/main/java/processing/data/FloatList.java +167 -54
- data/src/main/java/processing/data/IntDict.java +211 -56
- data/src/main/java/processing/data/IntList.java +185 -52
- data/src/main/java/processing/data/JSONArray.java +69 -20
- data/src/main/java/processing/data/JSONObject.java +53 -12
- data/src/main/java/processing/data/Sort.java +40 -10
- data/src/main/java/processing/data/StringDict.java +159 -49
- data/src/main/java/processing/data/StringList.java +147 -42
- data/src/main/java/processing/data/Table.java +778 -223
- data/src/main/java/processing/data/TableRow.java +26 -2
- data/src/main/java/processing/data/XML.java +190 -50
- data/src/main/java/processing/event/Event.java +93 -0
- data/src/main/java/processing/event/KeyEvent.java +55 -13
- data/src/main/java/processing/event/MouseEvent.java +77 -1
- data/src/main/java/processing/event/TouchEvent.java +14 -1
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +8 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +228 -66
- data/src/main/java/processing/opengl/LinePath.java +131 -27
- data/src/main/java/processing/opengl/LineStroker.java +30 -5
- data/src/main/java/processing/opengl/PGL.java +4066 -865
- data/src/main/java/processing/opengl/PGraphics2D.java +38 -10
- data/src/main/java/processing/opengl/PGraphics3D.java +38 -6
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +1980 -474
- data/src/main/java/processing/opengl/PJOGL.java +1460 -248
- data/src/main/java/processing/opengl/PShader.java +904 -217
- data/src/main/java/processing/opengl/PShapeOpenGL.java +1811 -487
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +278 -71
- data/src/main/java/processing/opengl/Texture.java +610 -135
- data/src/main/java/processing/opengl/VertexBuffer.java +45 -9
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +13 -6
- data/docs/assets/circle_collisions.png +0 -0
- data/docs/favicon.ico +0 -0
|
@@ -25,16 +25,27 @@ import processing.core.PApplet;
|
|
|
25
25
|
* @see StringList
|
|
26
26
|
*/
|
|
27
27
|
public class IntList implements Iterable<Integer> {
|
|
28
|
-
protected int count;
|
|
29
|
-
protected int[] data;
|
|
30
28
|
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
protected int count;
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
protected int[] data;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
public IntList() {
|
|
33
43
|
data = new int[10];
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
|
|
37
47
|
/**
|
|
48
|
+
* @param length
|
|
38
49
|
* @nowebref
|
|
39
50
|
*/
|
|
40
51
|
public IntList(int length) {
|
|
@@ -43,6 +54,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
/**
|
|
57
|
+
* @param source
|
|
46
58
|
* @nowebref
|
|
47
59
|
*/
|
|
48
60
|
public IntList(int[] source) {
|
|
@@ -53,9 +65,9 @@ public class IntList implements Iterable<Integer> {
|
|
|
53
65
|
|
|
54
66
|
|
|
55
67
|
/**
|
|
56
|
-
* Construct an IntList from an iterable pile of objects.
|
|
57
|
-
* For instance, a float array, an array of strings, who knows).
|
|
68
|
+
* Construct an IntList from an iterable pile of objects.For instance, a float array, an array of strings, who knows).
|
|
58
69
|
* Un-parseable or null values will be set to 0.
|
|
70
|
+
* @param iter
|
|
59
71
|
* @nowebref
|
|
60
72
|
*/
|
|
61
73
|
public IntList(Iterable<Object> iter) {
|
|
@@ -74,8 +86,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
74
86
|
|
|
75
87
|
|
|
76
88
|
/**
|
|
77
|
-
* Construct an IntList from a random pile of objects.
|
|
78
|
-
|
|
89
|
+
* Construct an IntList from a random pile of objects.Un-parseable or null values will be set to zero.
|
|
90
|
+
* @param items
|
|
79
91
|
*/
|
|
80
92
|
public IntList(Object... items) {
|
|
81
93
|
final int missingValue = 0; // nuts, can't be last/final/second arg
|
|
@@ -96,13 +108,22 @@ public class IntList implements Iterable<Integer> {
|
|
|
96
108
|
}
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @param stop
|
|
114
|
+
* @return
|
|
115
|
+
*/
|
|
116
|
+
static public IntList fromRange(int stop) {
|
|
101
117
|
return fromRange(0, stop);
|
|
102
118
|
}
|
|
103
119
|
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @param start
|
|
123
|
+
* @param stop
|
|
124
|
+
* @return
|
|
125
|
+
*/
|
|
126
|
+
static public IntList fromRange(int start, int stop) {
|
|
106
127
|
int count = stop - start;
|
|
107
128
|
IntList newbie = new IntList(count);
|
|
108
129
|
for (int i = 0; i < count; i++) {
|
|
@@ -128,6 +149,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
128
149
|
/**
|
|
129
150
|
* Get the length of the list.
|
|
130
151
|
*
|
|
152
|
+
* @return
|
|
131
153
|
* @webref intlist:method
|
|
132
154
|
* @brief Get the length of the list
|
|
133
155
|
*/
|
|
@@ -135,8 +157,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
135
157
|
return count;
|
|
136
158
|
}
|
|
137
159
|
|
|
138
|
-
|
|
139
|
-
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
* @param length
|
|
163
|
+
*/
|
|
164
|
+
public void resize(int length) {
|
|
140
165
|
if (length > data.length) {
|
|
141
166
|
int[] temp = new int[length];
|
|
142
167
|
System.arraycopy(data, 0, temp, 0, count);
|
|
@@ -163,6 +188,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
163
188
|
/**
|
|
164
189
|
* Get an entry at a particular index.
|
|
165
190
|
*
|
|
191
|
+
* @param index
|
|
192
|
+
* @return
|
|
166
193
|
* @webref intlist:method
|
|
167
194
|
* @brief Get an entry at a particular index
|
|
168
195
|
*/
|
|
@@ -175,10 +202,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
175
202
|
|
|
176
203
|
|
|
177
204
|
/**
|
|
178
|
-
* Set the entry at a particular index.
|
|
179
|
-
|
|
180
|
-
|
|
205
|
+
* Set the entry at a particular index.If the index is past the length of
|
|
206
|
+
the list, it'll expand the list to accommodate, and fill the intermediate
|
|
207
|
+
entries with 0s.
|
|
181
208
|
*
|
|
209
|
+
* @param index
|
|
210
|
+
* @param what
|
|
182
211
|
* @webref intlist:method
|
|
183
212
|
* @brief Set the entry at a particular index
|
|
184
213
|
*/
|
|
@@ -194,13 +223,17 @@ public class IntList implements Iterable<Integer> {
|
|
|
194
223
|
}
|
|
195
224
|
|
|
196
225
|
|
|
197
|
-
/** Just an alias for append(), but matches pop()
|
|
226
|
+
/** Just an alias for append(), but matches pop()
|
|
227
|
+
* @param value */
|
|
198
228
|
public void push(int value) {
|
|
199
229
|
append(value);
|
|
200
230
|
}
|
|
201
231
|
|
|
202
|
-
|
|
203
|
-
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @return
|
|
235
|
+
*/
|
|
236
|
+
public int pop() {
|
|
204
237
|
if (count == 0) {
|
|
205
238
|
throw new RuntimeException("Can't call pop() on an empty list");
|
|
206
239
|
}
|
|
@@ -213,6 +246,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
213
246
|
/**
|
|
214
247
|
* Remove an element from the specified index
|
|
215
248
|
*
|
|
249
|
+
* @param index
|
|
250
|
+
* @return
|
|
216
251
|
* @webref intlist:method
|
|
217
252
|
* @brief Remove an element from the specified index
|
|
218
253
|
*/
|
|
@@ -238,6 +273,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
238
273
|
|
|
239
274
|
// Remove the first instance of a particular value,
|
|
240
275
|
// and return the index at which it was found.
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
* @param value
|
|
280
|
+
* @return
|
|
281
|
+
*/
|
|
241
282
|
public int removeValue(int value) {
|
|
242
283
|
int index = index(value);
|
|
243
284
|
if (index != -1) {
|
|
@@ -250,6 +291,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
250
291
|
|
|
251
292
|
// Remove all instances of a particular value,
|
|
252
293
|
// and return the number of values found and removed
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param value
|
|
298
|
+
* @return
|
|
299
|
+
*/
|
|
253
300
|
public int removeValues(int value) {
|
|
254
301
|
int ii = 0;
|
|
255
302
|
for (int i = 0; i < count; i++) {
|
|
@@ -266,6 +313,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
266
313
|
/**
|
|
267
314
|
* Add a new entry to the list.
|
|
268
315
|
*
|
|
316
|
+
* @param value
|
|
269
317
|
* @webref intlist:method
|
|
270
318
|
* @brief Add a new entry to the list
|
|
271
319
|
*/
|
|
@@ -276,22 +324,29 @@ public class IntList implements Iterable<Integer> {
|
|
|
276
324
|
data[count++] = value;
|
|
277
325
|
}
|
|
278
326
|
|
|
279
|
-
|
|
280
|
-
|
|
327
|
+
/**
|
|
328
|
+
*
|
|
329
|
+
* @param values
|
|
330
|
+
*/
|
|
331
|
+
public void append(int[] values) {
|
|
281
332
|
for (int v : values) {
|
|
282
333
|
append(v);
|
|
283
334
|
}
|
|
284
335
|
}
|
|
285
336
|
|
|
286
|
-
|
|
287
|
-
|
|
337
|
+
/**
|
|
338
|
+
*
|
|
339
|
+
* @param list
|
|
340
|
+
*/
|
|
341
|
+
public void append(IntList list) {
|
|
288
342
|
for (int v : list.values()) { // will concat the list...
|
|
289
343
|
append(v);
|
|
290
344
|
}
|
|
291
345
|
}
|
|
292
346
|
|
|
293
347
|
|
|
294
|
-
/** Add this value, but only if it's not already in the list.
|
|
348
|
+
/** Add this value, but only if it's not already in the list.
|
|
349
|
+
* @param value */
|
|
295
350
|
public void appendUnique(int value) {
|
|
296
351
|
if (!hasValue(value)) {
|
|
297
352
|
append(value);
|
|
@@ -328,6 +383,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
328
383
|
// }
|
|
329
384
|
// }
|
|
330
385
|
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @param index
|
|
389
|
+
* @param value
|
|
390
|
+
*/
|
|
391
|
+
|
|
331
392
|
|
|
332
393
|
public void insert(int index, int value) {
|
|
333
394
|
insert(index, new int[] { value });
|
|
@@ -335,6 +396,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
335
396
|
|
|
336
397
|
|
|
337
398
|
// same as splice
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
*
|
|
402
|
+
* @param index
|
|
403
|
+
* @param values
|
|
404
|
+
*/
|
|
338
405
|
public void insert(int index, int[] values) {
|
|
339
406
|
if (index < 0) {
|
|
340
407
|
throw new IllegalArgumentException("insert() index cannot be negative: it was " + index);
|
|
@@ -362,8 +429,12 @@ public class IntList implements Iterable<Integer> {
|
|
|
362
429
|
data = temp;
|
|
363
430
|
}
|
|
364
431
|
|
|
365
|
-
|
|
366
|
-
|
|
432
|
+
/**
|
|
433
|
+
*
|
|
434
|
+
* @param index
|
|
435
|
+
* @param list
|
|
436
|
+
*/
|
|
437
|
+
public void insert(int index, IntList list) {
|
|
367
438
|
insert(index, list.values());
|
|
368
439
|
}
|
|
369
440
|
|
|
@@ -411,7 +482,9 @@ public class IntList implements Iterable<Integer> {
|
|
|
411
482
|
// }
|
|
412
483
|
|
|
413
484
|
|
|
414
|
-
/** Return the first index of a particular value.
|
|
485
|
+
/** Return the first index of a particular value.
|
|
486
|
+
* @param what
|
|
487
|
+
* @return */
|
|
415
488
|
public int index(int what) {
|
|
416
489
|
/*
|
|
417
490
|
if (indexCache != null) {
|
|
@@ -441,6 +514,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
441
514
|
// }
|
|
442
515
|
|
|
443
516
|
/**
|
|
517
|
+
* @param value
|
|
518
|
+
* @return
|
|
444
519
|
* @webref intlist:method
|
|
445
520
|
* @brief Check if a number is a part of the list
|
|
446
521
|
*/
|
|
@@ -458,6 +533,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
458
533
|
}
|
|
459
534
|
|
|
460
535
|
/**
|
|
536
|
+
* @param index
|
|
461
537
|
* @webref intlist:method
|
|
462
538
|
* @brief Add one to a value
|
|
463
539
|
*/
|
|
@@ -477,6 +553,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
477
553
|
|
|
478
554
|
|
|
479
555
|
/**
|
|
556
|
+
* @param index
|
|
557
|
+
* @param amount
|
|
480
558
|
* @webref intlist:method
|
|
481
559
|
* @brief Add to a value
|
|
482
560
|
*/
|
|
@@ -489,6 +567,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
489
567
|
}
|
|
490
568
|
|
|
491
569
|
/**
|
|
570
|
+
* @param index
|
|
571
|
+
* @param amount
|
|
492
572
|
* @webref intlist:method
|
|
493
573
|
* @brief Subtract from a value
|
|
494
574
|
*/
|
|
@@ -501,6 +581,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
501
581
|
}
|
|
502
582
|
|
|
503
583
|
/**
|
|
584
|
+
* @param index
|
|
585
|
+
* @param amount
|
|
504
586
|
* @webref intlist:method
|
|
505
587
|
* @brief Multiply a value
|
|
506
588
|
*/
|
|
@@ -513,6 +595,8 @@ public class IntList implements Iterable<Integer> {
|
|
|
513
595
|
}
|
|
514
596
|
|
|
515
597
|
/**
|
|
598
|
+
* @param index
|
|
599
|
+
* @param amount
|
|
516
600
|
* @webref intlist:method
|
|
517
601
|
* @brief Divide a value
|
|
518
602
|
*/
|
|
@@ -536,6 +620,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
536
620
|
|
|
537
621
|
|
|
538
622
|
/**
|
|
623
|
+
* @return
|
|
539
624
|
* @webref intlist:method
|
|
540
625
|
* @brief Return the smallest value
|
|
541
626
|
*/
|
|
@@ -551,6 +636,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
551
636
|
|
|
552
637
|
// returns the index of the minimum value.
|
|
553
638
|
// if there are ties, it returns the first one found.
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
*
|
|
642
|
+
* @return
|
|
643
|
+
*/
|
|
554
644
|
public int minIndex() {
|
|
555
645
|
checkMinMax("minIndex");
|
|
556
646
|
int value = data[0];
|
|
@@ -566,6 +656,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
566
656
|
|
|
567
657
|
|
|
568
658
|
/**
|
|
659
|
+
* @return
|
|
569
660
|
* @webref intlist:method
|
|
570
661
|
* @brief Return the largest value
|
|
571
662
|
*/
|
|
@@ -581,6 +672,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
581
672
|
|
|
582
673
|
// returns the index of the maximum value.
|
|
583
674
|
// if there are ties, it returns the first one found.
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
*
|
|
678
|
+
* @return
|
|
679
|
+
*/
|
|
584
680
|
public int maxIndex() {
|
|
585
681
|
checkMinMax("maxIndex");
|
|
586
682
|
int value = data[0];
|
|
@@ -594,8 +690,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
594
690
|
return index;
|
|
595
691
|
}
|
|
596
692
|
|
|
597
|
-
|
|
598
|
-
|
|
693
|
+
/**
|
|
694
|
+
*
|
|
695
|
+
* @return
|
|
696
|
+
*/
|
|
697
|
+
public int sum() {
|
|
599
698
|
long amount = sumLong();
|
|
600
699
|
if (amount > Integer.MAX_VALUE) {
|
|
601
700
|
throw new RuntimeException("sum() exceeds " + Integer.MAX_VALUE + ", use sumLong()");
|
|
@@ -606,8 +705,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
606
705
|
return (int) amount;
|
|
607
706
|
}
|
|
608
707
|
|
|
609
|
-
|
|
610
|
-
|
|
708
|
+
/**
|
|
709
|
+
*
|
|
710
|
+
* @return
|
|
711
|
+
*/
|
|
712
|
+
public long sumLong() {
|
|
611
713
|
long sum = 0;
|
|
612
714
|
for (int i = 0; i < count; i++) {
|
|
613
715
|
sum += data[i];
|
|
@@ -710,6 +812,7 @@ public class IntList implements Iterable<Integer> {
|
|
|
710
812
|
/**
|
|
711
813
|
* Randomize the list order using the random() function from the specified
|
|
712
814
|
* sketch, allowing shuffle() to use its current randomSeed() setting.
|
|
815
|
+
* @param sketch
|
|
713
816
|
*/
|
|
714
817
|
public void shuffle(PApplet sketch) {
|
|
715
818
|
int num = count;
|
|
@@ -722,8 +825,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
722
825
|
}
|
|
723
826
|
}
|
|
724
827
|
|
|
725
|
-
|
|
726
|
-
|
|
828
|
+
/**
|
|
829
|
+
*
|
|
830
|
+
* @return
|
|
831
|
+
*/
|
|
832
|
+
public IntList copy() {
|
|
727
833
|
IntList outgoing = new IntList(data);
|
|
728
834
|
outgoing.count = count;
|
|
729
835
|
return outgoing;
|
|
@@ -731,17 +837,21 @@ public class IntList implements Iterable<Integer> {
|
|
|
731
837
|
|
|
732
838
|
|
|
733
839
|
/**
|
|
734
|
-
* Returns the actual array being used to store the data.
|
|
735
|
-
|
|
736
|
-
|
|
840
|
+
* Returns the actual array being used to store the data.For advanced users,
|
|
841
|
+
this is the fastest way to access a large list. Suitable for iterating
|
|
842
|
+
with a for() loop, but modifying the list will have terrible consequences.
|
|
843
|
+
* @return
|
|
737
844
|
*/
|
|
738
845
|
public int[] values() {
|
|
739
846
|
crop();
|
|
740
847
|
return data;
|
|
741
848
|
}
|
|
742
849
|
|
|
743
|
-
|
|
744
|
-
|
|
850
|
+
/**
|
|
851
|
+
*
|
|
852
|
+
* @return
|
|
853
|
+
*/
|
|
854
|
+
@Override
|
|
745
855
|
public Iterator<Integer> iterator() {
|
|
746
856
|
// public Iterator<Integer> valueIterator() {
|
|
747
857
|
return new Iterator<Integer>() {
|
|
@@ -776,9 +886,10 @@ public class IntList implements Iterable<Integer> {
|
|
|
776
886
|
|
|
777
887
|
|
|
778
888
|
/**
|
|
779
|
-
* Copy values into the specified array.
|
|
780
|
-
|
|
889
|
+
* Copy values into the specified array.If the specified array is null or
|
|
890
|
+
not the same size, a new array will be allocated.
|
|
781
891
|
* @param array
|
|
892
|
+
* @return
|
|
782
893
|
*/
|
|
783
894
|
public int[] array(int[] array) {
|
|
784
895
|
if (array == null || array.length != count) {
|
|
@@ -833,10 +944,11 @@ public class IntList implements Iterable<Integer> {
|
|
|
833
944
|
|
|
834
945
|
|
|
835
946
|
/**
|
|
836
|
-
* Returns a normalized version of this array.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
947
|
+
* Returns a normalized version of this array.Called getPercent() for
|
|
948
|
+
consistency with the Dict classes. It's a getter method because it needs
|
|
949
|
+
to returns a new list (because IntList/Dict can't do percentages or
|
|
950
|
+
normalization in place on int values).
|
|
951
|
+
* @return
|
|
840
952
|
*/
|
|
841
953
|
public FloatList getPercent() {
|
|
842
954
|
double sum = 0;
|
|
@@ -864,20 +976,35 @@ public class IntList implements Iterable<Integer> {
|
|
|
864
976
|
// return outgoing;
|
|
865
977
|
// }
|
|
866
978
|
|
|
979
|
+
/**
|
|
980
|
+
*
|
|
981
|
+
* @param start
|
|
982
|
+
* @return
|
|
983
|
+
*/
|
|
984
|
+
|
|
867
985
|
|
|
868
986
|
public IntList getSubset(int start) {
|
|
869
987
|
return getSubset(start, count - start);
|
|
870
988
|
}
|
|
871
989
|
|
|
872
|
-
|
|
873
|
-
|
|
990
|
+
/**
|
|
991
|
+
*
|
|
992
|
+
* @param start
|
|
993
|
+
* @param num
|
|
994
|
+
* @return
|
|
995
|
+
*/
|
|
996
|
+
public IntList getSubset(int start, int num) {
|
|
874
997
|
int[] subset = new int[num];
|
|
875
998
|
System.arraycopy(data, start, subset, 0, num);
|
|
876
999
|
return new IntList(subset);
|
|
877
1000
|
}
|
|
878
1001
|
|
|
879
|
-
|
|
880
|
-
|
|
1002
|
+
/**
|
|
1003
|
+
*
|
|
1004
|
+
* @param separator
|
|
1005
|
+
* @return
|
|
1006
|
+
*/
|
|
1007
|
+
public String join(String separator) {
|
|
881
1008
|
if (count == 0) {
|
|
882
1009
|
return "";
|
|
883
1010
|
}
|
|
@@ -890,8 +1017,10 @@ public class IntList implements Iterable<Integer> {
|
|
|
890
1017
|
return sb.toString();
|
|
891
1018
|
}
|
|
892
1019
|
|
|
893
|
-
|
|
894
|
-
|
|
1020
|
+
/**
|
|
1021
|
+
*
|
|
1022
|
+
*/
|
|
1023
|
+
public void print() {
|
|
895
1024
|
for (int i = 0; i < count; i++) {
|
|
896
1025
|
System.out.format("[%d] %d%n", i, data[i]);
|
|
897
1026
|
}
|
|
@@ -900,13 +1029,17 @@ public class IntList implements Iterable<Integer> {
|
|
|
900
1029
|
|
|
901
1030
|
/**
|
|
902
1031
|
* Return this dictionary as a String in JSON format.
|
|
1032
|
+
* @return
|
|
903
1033
|
*/
|
|
904
1034
|
public String toJSON() {
|
|
905
1035
|
return "[ " + join(", ") + " ]";
|
|
906
1036
|
}
|
|
907
1037
|
|
|
908
|
-
|
|
909
|
-
|
|
1038
|
+
/**
|
|
1039
|
+
*
|
|
1040
|
+
* @return
|
|
1041
|
+
*/
|
|
1042
|
+
@Override
|
|
910
1043
|
public String toString() {
|
|
911
1044
|
return getClass().getSimpleName() + " size=" + size() + " " + toJSON();
|
|
912
1045
|
}
|