add suport for iterating over dictionary entries, cleaning up todo list

This commit is contained in:
Ben Fry
2016-11-14 21:27:21 -05:00
parent 4af8d568b5
commit 09950036c0
4 changed files with 150 additions and 8 deletions
+49
View File
@@ -127,6 +127,55 @@ public class FloatDict {
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public class Entry {
public String key;
public float value;
Entry(String key, float value) {
this.key = key;
this.value = value;
}
}
public Iterable<Entry> entries() {
return new Iterable<Entry>() {
public Iterator<Entry> iterator() {
return entryIterator();
}
};
}
public Iterator<Entry> entryIterator() {
return new Iterator<Entry>() {
int index = -1;
public void remove() {
removeIndex(index);
index--;
}
public Entry next() {
Entry e = new Entry(keys[index], values[index]);
index++;
return e;
}
public boolean hasNext() {
return index+1 < size();
}
};
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public String key(int index) {
return keys[index];
}
+49
View File
@@ -128,6 +128,55 @@ public class IntDict {
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public class Entry {
public String key;
public int value;
Entry(String key, int value) {
this.key = key;
this.value = value;
}
}
public Iterable<Entry> entries() {
return new Iterable<Entry>() {
public Iterator<Entry> iterator() {
return entryIterator();
}
};
}
public Iterator<Entry> entryIterator() {
return new Iterator<Entry>() {
int index = -1;
public void remove() {
removeIndex(index);
index--;
}
public Entry next() {
Entry e = new Entry(keys[index], values[index]);
index++;
return e;
}
public boolean hasNext() {
return index+1 < size();
}
};
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public String key(int index) {
return keys[index];
}
+49
View File
@@ -129,6 +129,55 @@ public class StringDict {
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public class Entry {
public String key;
public String value;
Entry(String key, String value) {
this.key = key;
this.value = value;
}
}
public Iterable<Entry> entries() {
return new Iterable<Entry>() {
public Iterator<Entry> iterator() {
return entryIterator();
}
};
}
public Iterator<Entry> entryIterator() {
return new Iterator<Entry>() {
int index = -1;
public void remove() {
removeIndex(index);
index--;
}
public Entry next() {
Entry e = new Entry(keys[index], values[index]);
index++;
return e;
}
public boolean hasNext() {
return index+1 < size();
}
};
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public String key(int index) {
return keys[index];
}
+3 -8
View File
@@ -1,18 +1,19 @@
0256 (3.2.4 or 3.3)
X write exec() documentation
X https://github.com/processing/processing/issues/4740
api additions
X add listPaths(), listFiles()
X https://github.com/processing/processing/issues/4622
_ needs documentation
X add increment() method that takes IntDict to merge another dictionary
X Calling this increment() since it doesn't make sense in practice for
X the other dictionary types, even though it's technically an add()
X add Entry class for iterating StringDict, IntDict, FloatDict
contribs
X Adding missing docs and keywords for TableRow
X https://github.com/processing/processing/pull/4333
_ add StringDict.Entry class for iterating
_ TRIANGLE_STRIP not working correctly with createShape() and default renderer
_ https://github.com/processing/processing/issues/4678
@@ -109,7 +110,6 @@ _ https://www.linkedin.com/pulse/oracle-just-removed-javafx-support-arm-jan-sn
opengl questions
_ hard crash at 1920x1080, mirrored, Casey's GT 650M 1GB
_ exitCalled() and exitActual made public by Andres, breaks Python
_ also not API we want to expose, so sort this out
_ or maybe we're fine b/c now FX2D needs it as well
@@ -191,11 +191,6 @@ _ at least with the Java2D renderer
_ don't override the window icon w/ p5 logo if already set
retina/hidpi
_ no high-dpi support for core on Windows
_ https://github.com/processing/processing/issues/2411
decisions/misc
_ Separately, if we wanted, we could add a method that can safely do drawing calls, but that won't be any faster or make use of more processors the way that `thread()` does.
_ need reference update for createShape()