mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
bug fixing on Dict and List classes, add Iterable constructor
This commit is contained in:
@@ -70,6 +70,9 @@ public class FloatDict {
|
||||
this.keys = keys;
|
||||
this.values = values;
|
||||
count = keys.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
indices.put(keys[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +84,7 @@ public class FloatDict {
|
||||
/** Remove all entries. */
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,13 @@ public class FloatList implements Iterable<Float> {
|
||||
}
|
||||
|
||||
|
||||
public FloatList(Iterable<Float> iter) {
|
||||
this(10);
|
||||
for (float v : iter) {
|
||||
append(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Improve efficiency by removing allocated but unused entries from the
|
||||
|
||||
@@ -93,6 +93,9 @@ public class IntDict {
|
||||
this.keys = keys;
|
||||
this.values = values;
|
||||
count = keys.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
indices.put(keys[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +107,7 @@ public class IntDict {
|
||||
/** Remove all entries. */
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,14 @@ public class IntList implements Iterable<Integer> {
|
||||
}
|
||||
|
||||
|
||||
public IntList(Iterable<Integer> iter) {
|
||||
this(10);
|
||||
for (int v : iter) {
|
||||
append(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Improve efficiency by removing allocated but unused entries from the
|
||||
* internal array used to store the data. Set to private, though it could
|
||||
|
||||
@@ -68,6 +68,9 @@ public class StringDict {
|
||||
this.keys = keys;
|
||||
this.values = values;
|
||||
count = keys.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
indices.put(keys[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +82,7 @@ public class StringDict {
|
||||
/** Remove all entries. */
|
||||
public void clear() {
|
||||
count = 0;
|
||||
indices = new HashMap<String, Integer>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,15 @@ public class StringList implements Iterable<String> {
|
||||
}
|
||||
|
||||
|
||||
// Create from something iterable, for instance:
|
||||
// StringList list = new StringList(hashMap.keySet());
|
||||
public StringList(Iterable<String> iter) {
|
||||
this(10);
|
||||
for (String s : iter) {
|
||||
append(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Improve efficiency by removing allocated but unused entries from the
|
||||
|
||||
@@ -3391,7 +3391,7 @@ public class Table {
|
||||
|
||||
public StringDict getStringDict(int keyColumn, int valueColumn) {
|
||||
return new StringDict(getStringColumn(keyColumn),
|
||||
getStringColumn(valueColumn));
|
||||
getStringColumn(valueColumn));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user