Skip to content

Commit c82cdc2

Browse files
committed
more massaging, also tweak Table accessors for types
1 parent 442ad2f commit c82cdc2

File tree

7 files changed

+178
-80
lines changed

7 files changed

+178
-80
lines changed

core/src/processing/data/FloatHash.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,19 @@ public void set(String key, int amount) {
246246
}
247247

248248

249-
/** Increase the value of a specific key by 1. */
250-
public void inc(String key) {
251-
inc(key, 1);
252-
// int index = index(key);
253-
// if (index == -1) {
254-
// create(key, 1);
255-
// } else {
256-
// values[index]++;
257-
// }
258-
}
249+
// /** Increase the value of a specific key by 1. */
250+
// public void inc(String key) {
251+
// inc(key, 1);
252+
//// int index = index(key);
253+
//// if (index == -1) {
254+
//// create(key, 1);
255+
//// } else {
256+
//// values[index]++;
257+
//// }
258+
// }
259259

260260

261-
public void inc(String key, float amount) {
261+
public void add(String key, float amount) {
262262
int index = index(key);
263263
if (index == -1) {
264264
create(key, amount);
@@ -268,14 +268,14 @@ public void inc(String key, float amount) {
268268
}
269269

270270

271-
/** Decrease the value of a key by 1. */
272-
public void dec(String key) {
273-
inc(key, -1);
274-
}
271+
// /** Decrease the value of a key by 1. */
272+
// public void dec(String key) {
273+
// inc(key, -1);
274+
// }
275275

276276

277-
public void dec(String key, float amount) {
278-
inc(key, -amount);
277+
public void sub(String key, float amount) {
278+
add(key, -amount);
279279
}
280280

281281

core/src/processing/data/IntHash.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ public void set(String key, int amount) {
236236

237237

238238
/** Increase the value of a specific key by 1. */
239-
public void inc(String key) {
240-
inc(key, 1);
239+
public void increment(String key) {
240+
add(key, 1);
241241
}
242242

243243

244-
public void inc(String key, int amount) {
244+
public void add(String key, int amount) {
245245
int index = index(key);
246246
if (index == -1) {
247247
create(key, amount);
@@ -251,14 +251,8 @@ public void inc(String key, int amount) {
251251
}
252252

253253

254-
/** Decrease the value of a key by 1. */
255-
public void dec(String key) {
256-
inc(key, -1);
257-
}
258-
259-
260-
public void dec(String key, int amount) {
261-
inc(key, -amount);
254+
public void sub(String key, int amount) {
255+
add(key, -amount);
262256
}
263257

264258

core/src/processing/data/JSONArray.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,56 @@ public JSONObject getJSONObject(int index) {
392392
}
393393

394394

395+
/** Get this entire array as an int array. Everything must be an int. */
396+
public int[] getIntArray() {
397+
int[] outgoing = new int[size()];
398+
for (int i = 0; i < size(); i++) {
399+
outgoing[i] = getInt(i);
400+
}
401+
return outgoing;
402+
}
403+
404+
405+
/** Get this entire array as a long array. Everything must be an long. */
406+
public long[] getLongArray() {
407+
long[] outgoing = new long[size()];
408+
for (int i = 0; i < size(); i++) {
409+
outgoing[i] = getLong(i);
410+
}
411+
return outgoing;
412+
}
413+
414+
415+
/** Get this entire array as a float array. Everything must be an float. */
416+
public float[] getFloatArray() {
417+
float[] outgoing = new float[size()];
418+
for (int i = 0; i < size(); i++) {
419+
outgoing[i] = getFloat(i);
420+
}
421+
return outgoing;
422+
}
423+
424+
425+
/** Get this entire array as a double array. Everything must be an double. */
426+
public double[] getDoubleArray() {
427+
double[] outgoing = new double[size()];
428+
for (int i = 0; i < size(); i++) {
429+
outgoing[i] = getDouble(i);
430+
}
431+
return outgoing;
432+
}
433+
434+
435+
/** Get this entire array as a boolean array. Everything must be a boolean. */
436+
public boolean[] getBooleanArray() {
437+
boolean[] outgoing = new boolean[size()];
438+
for (int i = 0; i < size(); i++) {
439+
outgoing[i] = getBoolean(i);
440+
}
441+
return outgoing;
442+
}
443+
444+
395445
// /**
396446
// * Get the optional boolean value associated with an index.
397447
// * It returns false if there is no value at that index,

core/src/processing/data/StringList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ public void unique() {
611611
public IntHash getTally() {
612612
IntHash outgoing = new IntHash();
613613
for (int i = 0; i < count; i++) {
614-
outgoing.inc(data[i]);
614+
outgoing.increment(data[i]);
615615
}
616616
return outgoing;
617617
}

0 commit comments

Comments
 (0)