diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 5c01e3d20..81bbd99a6 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -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 entries() { + return new Iterable() { + + public Iterator iterator() { + return entryIterator(); + } + }; + } + + + public Iterator entryIterator() { + return new Iterator() { + 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]; } diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index accdf7393..57d045d4c 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -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 entries() { + return new Iterable() { + + public Iterator iterator() { + return entryIterator(); + } + }; + } + + + public Iterator entryIterator() { + return new Iterator() { + 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]; } diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index 5231c44d4..3768f6953 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -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 entries() { + return new Iterable() { + + public Iterator iterator() { + return entryIterator(); + } + }; + } + + + public Iterator entryIterator() { + return new Iterator() { + 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]; } diff --git a/core/todo.txt b/core/todo.txt index 60f91f817..0f7c8f2e1 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -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()