| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,28 @@ public FloatDict(BufferedReader reader) { | |||
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 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 | + | ||
| 71 | 93 | /** | |
| 72 | 94 | * @nowebref | |
| 73 | 95 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,6 +83,28 @@ public IntDict(String[] keys, int[] values) { | |||
| 83 | 83 | } | |
| 84 | 84 | } | |
| 85 | 85 | ||
| 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 | + | ||
| 86 | 108 | /** | |
| 87 | 109 | * Returns the number of key/value pairs | |
| 88 | 110 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,6 +69,7 @@ public StringDict(BufferedReader reader) { | |||
| 69 | 69 | } | |
| 70 | 70 | } | |
| 71 | 71 | ||
| 72 | + | ||
| 72 | 73 | /** | |
| 73 | 74 | * @nowebref | |
| 74 | 75 | */ | |
@@ -84,6 +85,29 @@ public StringDict(String[] keys, String[] values) { | |||
| 84 | 85 | } | |
| 85 | 86 | } | |
| 86 | 87 | ||
| 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 | + | ||
| 87 | 111 | /** | |
| 88 | 112 | * @webref stringdict:method | |
| 89 | 113 | * @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 | |||
| 3 | 3 | X fairly major rewrite of createShape() | |
| 4 | 4 | X prevents same code from appearing 5x (!) in the source | |
| 5 | 5 | X improves bad api design with the static createShapeImpl() methods | |
| 6 | + X add new String/Int/FloatDict constructors for easier initialization | ||
| 6 | 7 | ||
| 7 | 8 | ||
| 8 | 9 | _ need reference update for createShape() | |
@@ -128,6 +129,7 @@ _ https://github.com/processing/processing/issues/2778 | |||
| 128 | 129 | _ make join() work with Iterable? | |
| 129 | 130 | _ will this collide with the current String[] version? | |
| 130 | 131 | _ remove OPENGL constant (tell people to use P3D or P2D) | |
| 132 | + _ exec() and open() to use varargs | ||
| 131 | 133 | ||
| 132 | 134 | ||
| 133 | 135 | under consideration | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,9 @@ contribs | |||
| 9 | 9 | X Window size not passing into Tweak Mode | |
| 10 | 10 | X https://github.com/processing/processing/issues/3208 | |
| 11 | 11 | X 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 | ||
| 12 | 15 | ||
| 13 | 16 | ||
| 14 | 17 | _ we've lost arrow keys to expand items in the examples window | |
| Back | FazBrowse Home | New Git URL |
0 commit comments