mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
construct a DoubleDict from a Map
This commit is contained in:
@@ -3,6 +3,7 @@ package processing.data;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.core.PApplet;
|
||||
|
||||
@@ -106,6 +107,20 @@ public class DoubleDict {
|
||||
}
|
||||
|
||||
|
||||
public DoubleDict(Map<String, Double> incoming) {
|
||||
count = incoming.size();
|
||||
keys = new String[count];
|
||||
values = new double[count];
|
||||
int index = 0;
|
||||
for (Map.Entry<String, Double> e : incoming.entrySet()) {
|
||||
keys[index] = e.getKey();
|
||||
values[index] = e.getValue();
|
||||
indices.put(keys[index], index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref doubledict:method
|
||||
* @brief Returns the number of key/value pairs
|
||||
|
||||
Reference in New Issue
Block a user