mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 13:49:18 +01:00
add suport for iterating over dictionary entries, cleaning up todo list
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user