Skip to content

Commit 3bfdc48

Browse files
committed
Changes to Dict and List classes for reference
1 parent 7a5085b commit 3bfdc48

7 files changed

Lines changed: 562 additions & 60 deletions

File tree

core/src/processing/data/FloatDict.java

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,21 @@ public FloatDict(String[] keys, float[] values) {
7777
}
7878
}
7979

80-
80+
/**
81+
* @webref floatdict:method
82+
* @brief To come...
83+
*/
8184
public int size() {
8285
return count;
8386
}
8487

8588

86-
/** Remove all entries. */
89+
/**
90+
* Remove all entries.
91+
*
92+
* @webref floatdict:method
93+
* @brief Remove all entries
94+
*/
8795
public void clear() {
8896
count = 0;
8997
indices = new HashMap<String, Integer>();
@@ -112,7 +120,10 @@ protected void crop() {
112120
// return keys;
113121
// }
114122

115-
123+
/**
124+
* @webref floatdict:method
125+
* @brief To come...
126+
*/
116127
public Iterable<String> keys() {
117128
return new Iterable<String>() {
118129

@@ -169,6 +180,9 @@ public void reset() {
169180

170181
/**
171182
* Return a copy of the internal keys array. This array can be modified.
183+
*
184+
* @webref floatdict:method
185+
* @brief Return a copy of the internal keys array
172186
*/
173187
public String[] keyArray() {
174188
return keyArray(null);
@@ -194,7 +208,10 @@ public float value(int index) {
194208
// return values;
195209
// }
196210

197-
211+
/**
212+
* @webref floatdict:method
213+
* @brief To come...
214+
*/
198215
public Iterable<Float> values() {
199216
return new Iterable<Float>() {
200217

@@ -222,6 +239,9 @@ public boolean hasNext() {
222239

223240
/**
224241
* Create a new array and copy each of the values into it.
242+
*
243+
* @webref floatdict:method
244+
* @brief Create a new array and copy each of the values into it
225245
*/
226246
public float[] valueArray() {
227247
return valueArray(null);
@@ -244,6 +264,9 @@ public float[] valueArray(float[] array) {
244264

245265
/**
246266
* Return a value for the specified key.
267+
*
268+
* @webref floatdict:method
269+
* @brief Return a value for the specified key
247270
*/
248271
public float get(String key) {
249272
int index = index(key);
@@ -252,6 +275,10 @@ public float get(String key) {
252275
}
253276

254277

278+
/**
279+
* @webref floatdict:method
280+
* @brief To come...
281+
*/
255282
public void set(String key, int amount) {
256283
int index = index(key);
257284
if (index == -1) {
@@ -262,6 +289,10 @@ public void set(String key, int amount) {
262289
}
263290

264291

292+
/**
293+
* @webref floatdict:method
294+
* @brief To come...
295+
*/
265296
public boolean hasKey(String key) {
266297
return index(key) != -1;
267298
}
@@ -279,6 +310,10 @@ public boolean hasKey(String key) {
279310
// }
280311

281312

313+
/**
314+
* @webref floatdict:method
315+
* @brief To come...
316+
*/
282317
public void add(String key, float amount) {
283318
int index = index(key);
284319
if (index == -1) {
@@ -295,11 +330,19 @@ public void add(String key, float amount) {
295330
// }
296331

297332

333+
/**
334+
* @webref floatdict:method
335+
* @brief To come...
336+
*/
298337
public void sub(String key, float amount) {
299338
add(key, -amount);
300339
}
301340

302341

342+
/**
343+
* @webref floatdict:method
344+
* @brief To come...
345+
*/
303346
public void mult(String key, float amount) {
304347
int index = index(key);
305348
if (index != -1) {
@@ -308,6 +351,10 @@ public void mult(String key, float amount) {
308351
}
309352

310353

354+
/**
355+
* @webref floatdict:method
356+
* @brief To come...
357+
*/
311358
public void div(String key, float amount) {
312359
int index = index(key);
313360
if (index != -1) {
@@ -343,6 +390,10 @@ protected void create(String what, float much) {
343390
}
344391

345392

393+
/**
394+
* @webref floatdict:method
395+
* @brief To come...
396+
*/
346397
public void remove(String key) {
347398
removeIndex(index(key));
348399
}
@@ -391,6 +442,9 @@ protected void swap(int a, int b) {
391442
/**
392443
* Sort the keys alphabetically (ignoring case). Uses the value as a
393444
* tie-breaker (only really possible with a key that has a case change).
445+
*
446+
* @webref floatdict:method
447+
* @brief Sort the keys alphabetically
394448
*/
395449
public void sortKeys() {
396450
sortImpl(true, false);
@@ -407,6 +461,10 @@ public void sortKeys() {
407461
}
408462

409463

464+
/**
465+
* @webref floatdict:method
466+
* @brief To come...
467+
*/
410468
public void sortKeysReverse() {
411469
sortImpl(true, true);
412470
// new InternalSort() {
@@ -424,6 +482,9 @@ public void sortKeysReverse() {
424482

425483
/**
426484
* Sort by values in descending order (largest value will be at [0]).
485+
*
486+
* @webref floatdict:method
487+
* @brief Sort by values in descending order
427488
*/
428489
public void sortValues() {
429490
sortImpl(false, false);
@@ -436,6 +497,10 @@ public void sortValues() {
436497
}
437498

438499

500+
/**
501+
* @webref floatdict:method
502+
* @brief To come...
503+
*/
439504
public void sortValuesReverse() {
440505
sortImpl(false, true);
441506
// new InternalSort() {

core/src/processing/data/FloatList.java

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ private void crop() {
5555

5656
/**
5757
* Get the length of the list.
58+
*
59+
* @webref floatlist:method
60+
* @brief Get the length of the list
5861
*/
5962
public int size() {
6063
return count;
@@ -76,6 +79,9 @@ public void resize(int length) {
7679

7780
/**
7881
* Remove all entries from the list.
82+
*
83+
* @webref floatlist:method
84+
* @brief Remove all entries from the list
7985
*/
8086
public void clear() {
8187
count = 0;
@@ -84,6 +90,9 @@ public void clear() {
8490

8591
/**
8692
* Get an entry at a particular index.
93+
*
94+
* @webref floatlist:method
95+
* @brief Get an entry at a particular index
8796
*/
8897
public float get(int index) {
8998
return data[index];
@@ -94,6 +103,9 @@ public float get(int index) {
94103
* Set the entry at a particular index. If the index is past the length of
95104
* the list, it'll expand the list to accommodate, and fill the intermediate
96105
* entries with 0s.
106+
*
107+
* @webref floatlist:method
108+
* @brief Set the entry at a particular index
97109
*/
98110
public void set(int index, float what) {
99111
if (index >= count) {
@@ -107,7 +119,12 @@ public void set(int index, float what) {
107119
}
108120

109121

110-
/** remove an element from the specified index */
122+
/**
123+
* Remove an element from the specified index.
124+
*
125+
* @webref floatlist:method
126+
* @brief Remove an element from the specified index
127+
*/
111128
public void remove(int index) {
112129
// int[] outgoing = new int[count - 1];
113130
// System.arraycopy(data, 0, outgoing, 0, index);
@@ -208,7 +225,12 @@ public boolean replaceValues(float value, float newValue) {
208225

209226

210227

211-
/** Add a new entry to the list. */
228+
/**
229+
* Add a new entry to the list.
230+
*
231+
* @webref floatlist:method
232+
* @brief Add a new entry to the list
233+
*/
212234
public void append(float value) {
213235
if (count == data.length) {
214236
data = PApplet.expand(data);
@@ -367,7 +389,10 @@ public int index(float what) {
367389
// }
368390
// }
369391

370-
392+
/**
393+
* @webref floatlist:method
394+
* @brief To come...
395+
*/
371396
public boolean hasValue(float value) {
372397
if (Float.isNaN(value)) {
373398
for (int i = 0; i < count; i++) {
@@ -391,27 +416,42 @@ public boolean hasValue(float value) {
391416
// data[index]++;
392417
// }
393418

394-
419+
/**
420+
* @webref floatlist:method
421+
* @brief To come...
422+
*/
395423
public void add(int index, float amount) {
396424
data[index] += amount;
397425
}
398426

399-
427+
/**
428+
* @webref floatlist:method
429+
* @brief To come...
430+
*/
400431
public void sub(int index, float amount) {
401432
data[index] -= amount;
402433
}
403434

404-
435+
/**
436+
* @webref floatlist:method
437+
* @brief To come...
438+
*/
405439
public void mult(int index, float amount) {
406440
data[index] *= amount;
407441
}
408442

409-
443+
/**
444+
* @webref floatlist:method
445+
* @brief To come...
446+
*/
410447
public void div(int index, float amount) {
411448
data[index] /= amount;
412449
}
413450

414-
451+
/**
452+
* @webref floatlist:method
453+
* @brief To come...
454+
*/
415455
public float min() {
416456
if (count == 0) {
417457
throw new ArrayIndexOutOfBoundsException("Cannot use min() on IntList of length 0.");
@@ -438,7 +478,10 @@ public float min() {
438478
return m;
439479
}
440480

441-
481+
/**
482+
* @webref floatlist:method
483+
* @brief To come...
484+
*/
442485
public float max() {
443486
if (count == 0) {
444487
throw new ArrayIndexOutOfBoundsException("Cannot use max() on IntList of length 0.");
@@ -466,13 +509,23 @@ public float max() {
466509
}
467510

468511

469-
/** Sorts the array in place. */
512+
/**
513+
* Sorts the array in place.
514+
*
515+
* @webref floatlist:method
516+
* @brief Sorts an array in place
517+
*/
470518
public void sort() {
471519
Arrays.sort(data, 0, count);
472520
}
473521

474522

475-
/** reverse sort, orders values from highest to lowest */
523+
/**
524+
* Reverse sort, orders values from highest to lowest
525+
*
526+
* @webref floatlist:method
527+
* @brief To come...
528+
*/
476529
public void sortReverse() {
477530
new Sort() {
478531
@Override
@@ -512,7 +565,10 @@ public void subset(int start, int num) {
512565
count = num;
513566
}
514567

515-
568+
/**
569+
* @webref floatlist:method
570+
* @brief To come...
571+
*/
516572
public void reverse() {
517573
int ii = count - 1;
518574
for (int i = 0; i < count/2; i++) {
@@ -527,6 +583,9 @@ public void reverse() {
527583
/**
528584
* Randomize the order of the list elements. Note that this does not
529585
* obey the randomSeed() function in PApplet.
586+
*
587+
* @webref floatlist:method
588+
* @brief Randomize the order of the list elements
530589
*/
531590
public void shuffle() {
532591
Random r = new Random();
@@ -603,6 +662,8 @@ public boolean hasNext() {
603662
/**
604663
* Create a new array with a copy of all the values.
605664
* @return an array sized by the length of the list with each of the values.
665+
* @webref floatlist:method
666+
* @brief Create a new array with a copy of all the values
606667
*/
607668
public int[] array() {
608669
return array(null);

0 commit comments

Comments
 (0)