Skip to content

Commit 936de4a

Browse files
committed
Updates to Int/Float/StringDict for reference
1 parent 576007d commit 936de4a

32 files changed

+439
-61
lines changed

content/api_en/FloatDict_add.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory); // There is 8.2 of tea
24+
inventory.add("tea", 1.1);
25+
println(inventory); // There is 9.3 of tea
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Add to a value.
2133
]]></description>
2234

2335
</root>

content/api_en/FloatDict_clear.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
inventory.clear();
25+
println(inventory);
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Remove all entries from the data structure.
2133
]]></description>
2234

2335
</root>

content/api_en/FloatDict_div.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory); // There is 8.2 of tea
24+
inventory.div("tea", 2);
25+
println(inventory); // There is 4.1 of tea
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Divide a value.
2133
]]></description>
2234

2335
</root>

content/api_en/FloatDict_get.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,30 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
noLoop();
25+
fill(0);
26+
textAlign(CENTER);
27+
}
28+
29+
void draw() {
30+
float coffeeWeight = inventory.get("coffee");
31+
text(coffeeWeight, width/2, height/2);
32+
}
33+
1634
]]></code>
1735
</example>
1836

1937
<description><![CDATA[
20-
To come...
38+
Return a value for the specified key.
2139
]]></description>
2240

2341
</root>

content/api_en/FloatDict_hasKey.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,27 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
if (inventory.hasKey("flour") == true) {
25+
println("Yes, we have flour.");
26+
} else {
27+
println("Sorry, no flour.");
28+
}
29+
}
30+
1631
]]></code>
1732
</example>
1833

1934
<description><![CDATA[
20-
To come...
35+
Check if a key is a part of the data structure.
2136
]]></description>
2237

2338
</root>

content/api_en/FloatDict_keyArray.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
String[] theKeys = inventory.keyArray();
25+
println(theKeys);
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Return a copy of the internal keys array. In contrast to the <b>keys()</b>
33+
method, this array can be modified.
2134
]]></description>
2235

2336
</root>

content/api_en/FloatDict_keys.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,26 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
String[] theKeys = inventory.keys();
25+
println(theKeys);
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Return the internal array being used to store the keys. Allocated
33+
but unused entries will be removed. In contrast to the <b>keyArray()</b>
34+
method, this array should not be modified.
2135
]]></description>
2236

2337
</root>

content/api_en/FloatDict_mult.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory); // There is 8.2 of tea
24+
inventory.mult("tea", 4);
25+
println(inventory); // There is 32.8 of tea
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Multiply a value.
2133
]]></description>
2234

2335
</root>

content/api_en/FloatDict_remove.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory); // Full inventory
24+
inventory.remove("flour");
25+
println(inventory); // Flour is removed from list
26+
}
27+
1628
]]></code>
1729
</example>
1830

1931
<description><![CDATA[
20-
To come...
32+
Remove a key/value pair.
2133
]]></description>
2234

2335
</root>

content/api_en/FloatDict_set.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@
1212
<example>
1313
<image></image>
1414
<code><![CDATA[
15-
To come...
15+
String[] goods = { "coffee", "flour", "tea"};
16+
float[] amounts = { 108.6, 5.8, 8.2 };
17+
18+
FloatDict inventory;
19+
20+
void setup() {
21+
size(200, 200);
22+
inventory = new FloatDict(goods, amounts);
23+
println(inventory);
24+
inventory.set("coffee", 12.4); // Less coffee
25+
inventory.set("sugar", 5.8); // Add sugar
26+
println(inventory);
27+
}
28+
1629
]]></code>
1730
</example>
1831

1932
<description><![CDATA[
20-
To come...
33+
Create a new key/value pair or change the value of one.
2134
]]></description>
2235

2336
</root>

0 commit comments

Comments
 (0)