more fixes for the data classes

This commit is contained in:
Ben Fry
2013-06-03 10:19:31 -04:00
parent 693004e798
commit 5e5c88e4c3
6 changed files with 340 additions and 109 deletions

View File

@@ -282,14 +282,19 @@ public class StringDict {
* @webref stringdict:method
* @brief Remove a key/value pair
*/
public void remove(String key) {
removeIndex(index(key));
public int remove(String key) {
int index = index(key);
if (index != -1) {
removeIndex(index);
}
return index;
}
public void removeIndex(int index) {
public String removeIndex(int index) {
//System.out.println("index is " + which + " and " + keys[which]);
indices.remove(keys[index]);
String key = keys[index];
indices.remove(key);
for (int i = index; i < count-1; i++) {
keys[i] = keys[i+1];
values[i] = values[i+1];
@@ -298,6 +303,7 @@ public class StringDict {
count--;
keys[count] = null;
values[count] = null;
return key;
}