add setIndex() method

This commit is contained in:
Ben Fry
2017-10-10 20:34:40 -04:00
parent 28ee67ff22
commit 2327009d88
3 changed files with 29 additions and 0 deletions

View File

@@ -363,11 +363,21 @@ public class StringDict {
}
public void setIndex(int index, String key, String value) {
if (index < 0 || index >= count) {
throw new ArrayIndexOutOfBoundsException(index);
}
keys[index] = key;
values[index] = value;
}
public int index(String what) {
Integer found = indices.get(what);
return (found == null) ? -1 : found.intValue();
}
/**
* @webref stringdict:method
* @brief Check if a key is a part of the data structure