File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,28 @@ public FloatDict(BufferedReader reader) {
6868 }
6969 }
7070
71+
72+ /**
73+ * Constructor to allow (more intuitive) inline initialization, e.g.:
74+ * <pre>
75+ * new FloatDict(new Object[][] {
76+ * { "key1", 1 },
77+ * { "key2", 2 }
78+ * });
79+ * </pre>
80+ */
81+ public FloatDict (Object [][] pairs ) {
82+ count = pairs .length ;
83+ this .keys = new String [count ];
84+ this .values = new float [count ];
85+ for (int i = 0 ; i < count ; i ++) {
86+ keys [i ] = (String ) pairs [i ][0 ];
87+ values [i ] = (Float ) pairs [i ][1 ];
88+ indices .put (keys [i ], i );
89+ }
90+ }
91+
92+
7193 /**
7294 * @nowebref
7395 */
Original file line number Diff line number Diff line change @@ -83,6 +83,28 @@ public IntDict(String[] keys, int[] values) {
8383 }
8484 }
8585
86+
87+ /**
88+ * Constructor to allow (more intuitive) inline initialization, e.g.:
89+ * <pre>
90+ * new FloatDict(new Object[][] {
91+ * { "key1", 1 },
92+ * { "key2", 2 }
93+ * });
94+ * </pre>
95+ */
96+ public IntDict (Object [][] pairs ) {
97+ count = pairs .length ;
98+ this .keys = new String [count ];
99+ this .values = new int [count ];
100+ for (int i = 0 ; i < count ; i ++) {
101+ keys [i ] = (String ) pairs [i ][0 ];
102+ values [i ] = (Integer ) pairs [i ][1 ];
103+ indices .put (keys [i ], i );
104+ }
105+ }
106+
107+
86108 /**
87109 * Returns the number of key/value pairs
88110 *
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public StringDict(BufferedReader reader) {
6969 }
7070 }
7171
72+
7273 /**
7374 * @nowebref
7475 */
@@ -84,6 +85,29 @@ public StringDict(String[] keys, String[] values) {
8485 }
8586 }
8687
88+
89+ /**
90+ * Constructor to allow (more intuitive) inline initialization, e.g.:
91+ * <pre>
92+ * new StringDict(new String[][] {
93+ * { "key1", "value1" },
94+ * { "key2", "value2" }
95+ * });
96+ * </pre>
97+ * It's no Python, but beats a static { } block with HashMap.put() statements.
98+ */
99+ public StringDict (String [][] pairs ) {
100+ count = pairs .length ;
101+ this .keys = new String [count ];
102+ this .values = new String [count ];
103+ for (int i = 0 ; i < count ; i ++) {
104+ keys [i ] = pairs [i ][0 ];
105+ values [i ] = pairs [i ][1 ];
106+ indices .put (keys [i ], i );
107+ }
108+ }
109+
110+
87111 /**
88112 * @webref stringdict:method
89113 * @brief Returns the number of key/value pairs
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ X pop() was not implemented correctly
33X fairly major rewrite of createShape()
44X prevents same code from appearing 5x (!) in the source
55X improves bad api design with the static createShapeImpl() methods
6+ X add new String/Int/FloatDict constructors for easier initialization
67
78
89_ need reference update for createShape()
@@ -128,6 +129,7 @@ _ https://github.com/processing/processing/issues/2778
128129_ make join() work with Iterable?
129130_ will this collide with the current String[] version?
130131_ remove OPENGL constant (tell people to use P3D or P2D)
132+ _ exec() and open() to use varargs
131133
132134
133135under consideration
Original file line number Diff line number Diff line change 99X Window size not passing into Tweak Mode
1010X https://github.com/processing/processing/issues/3208
1111X https://github.com/processing/processing/pull/3227
12+ X preferences window fixes for Linux
13+ X https://github.com/processing/processing/pull/3232
14+ X https://github.com/processing/processing/issues/3231
1215
1316
1417_ we've lost arrow keys to expand items in the examples window
You can’t perform that action at this time.
0 commit comments