Difference between revisions of "Dictionary class"

From Catglobe Wiki
Jump to: navigation, search
(Created page with "<p style="color:#000099; font-size:14px;"><strong>Dictionary : The dictionary object</strong></p> <p>  </p> <p> <span style="color:#a52a2a;"><strong>Constructors</strong><...")
 
Line 1: Line 1:
<p style="color:#000099; font-size:14px;"><strong>Dictionary : The dictionary object</strong></p>
+
'''Dictionary&nbsp;: The dictionary object'''
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Constructors</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>()</strong> - Create a new dictionary with non-argument.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>(Params&nbsp; AnyType)</strong> - Create new dictionary with the specified key-value pairs.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>(array keys,&nbsp; array values)</strong> - Create new dictionary with the specified keys and values.</span></li>
 
</ul>
 
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Methods</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Add(string key, AnyType value)</strong> - Adds the specified key and value to the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool Add(number key, AnyType value)</strong> - Adds the specified key and value to the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>Empty set_Item(string key, AnyType value)</strong> - Set an item based on a key and a value.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>Empty set_Item(number key, AnyType value)</strong> - Set an item based on a key and a value.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType get_Item(string key)</strong> - Get an item based on a key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType get_Item(number key)</strong> - Get an item based on a key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType TryGetValue(string key)</strong> - Gets the value associated with the specified key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType TryGetValue(number key)</strong> - Gets the value associated with the specified key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool ContainsKey(string key)</strong> - Determines whether the dictionary contains the specified key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool ContainsKey(number key)</strong> - Determines whether the dictionary contains the specified key.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>bool ContainsValue(AnyType value)</strong> - Determines whether the dictionary contains the specified value.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType Remove(string key)</strong> - Remove the value with the specified key from the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>AnyType Remove(number key)</strong> - Remove the value with the specified key from the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>Empty Clear()</strong> - Remove all keys and values from the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string ToString()</strong> - The string representation of the object.</span></li>
 
</ul>
 
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Properties</strong></span></p>
 
<ul>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>number Count HasGetter</strong>&nbsp; - Gets the number of key/value pairs contained in the dictionary.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>array Keys HasGetter</strong>&nbsp; - Gets a list of keys.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>string ObjectTypeName HasGetter</strong>&nbsp; - The name of the type of object.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>array SortedKeys HasGetter</strong>&nbsp; - Gets a list of keys sorted by current collation.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>TypeInformation TypeInformation HasGetter</strong>&nbsp; - Get information about this class.</span></li>
 
<li style="color:#000000;">
 
<span style="color:#000000;"><strong>array Values HasGetter</strong>&nbsp; - Gets a list of values.</span></li>
 
</ul>
 
<p>
 
&nbsp;</p>
 
<p>
 
<span style="color:#a52a2a;"><strong>Examples</strong></span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
Dictionary d;</p>
 
<p>
 
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; // {}</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
Dictionary d = new Dictionary();</p>
 
<p>
 
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">&nbsp;&nbsp; // {}</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
Dictionary d = {&quot;key1&quot;: 1, &quot;key2&quot;: 2};</p>
 
<p>
 
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// {&quot;key1&quot;: 1, &quot;key2&quot;: 2}</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
Dictionary d = {};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // Not work, will cause error.</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
Dictionary d1 = new Dictionary(&quot;key_01&quot;,&quot;value01&quot;);</p>
 
<p>
 
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> //&nbsp; {&quot;key_01&quot;: sdasd}</span></p>
 
<p>
 
print(d1.Add(&quot;key_02&quot;,2222));</p>
 
<p>
 
print(d1.Add(3,&quot;hello3333&quot;));</p>
 
<p>
 
print(d1.Add(&quot;key_03&quot;,{&quot;happy&quot;,48,{&quot;funny&quot;,&quot;sad&quot;,88}}));</p>
 
<p>
 
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; {&quot;3&quot;: hello3333, &quot;key_01&quot;: value01, &quot;key_02&quot;: 2222, &quot;key_03&quot;: {happy,48,{funny,sad,88}}}</span></p>
 
<p>
 
print(d1.ContainsKey(&quot;key_01&quot;));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // true</span></p>
 
<p>
 
print(d1.ContainsKey(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> // true</span></p>
 
<p>
 
print(d1.ContainsKey(&quot;noexist&quot;));&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">// false</span></p>
 
<p>
 
print(d1.ContainsValue(&quot;value01&quot;));&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // true</span></p>
 
<p>
 
print(d1.ContainsValue(2222));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#006400;">//&nbsp; true</span></p>
 
<p>
 
print(d1.ContainsValue({&quot;happy&quot;,48,{&quot;funny&quot;,&quot;sad&quot;,88}}));&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// true</span></p>
 
<p>
 
print(d1.get_Item(&quot;key_01&quot;));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<span style="color:#006400;"> // value01</span></p>
 
<p>
 
print(d1.get_Item(3)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; // hello3333</span></p>
 
<p>
 
print(d1.set_Item(&quot;key01&quot;,1111));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
 
<p>
 
print(d1.set_Item(3,{3333,&quot;string333&quot;}));</p>
 
<p>
 
print(d1.TryGetValue(&quot;key_01&quot;));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;"> // value01</span></p>
 
<p>
 
print(d1.TryGetValue(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <span style="color:#006400;">// {3333,&quot;string333&quot;}</span></p>
 
<p>
 
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; {&quot;3&quot;: {3333,string333}, &quot;key_01&quot;: value01, &quot;key_02&quot;: 2222, &quot;key_03&quot;: {happy,48,{funny,sad,88}}, &quot;key01&quot;: 1111}</span></p>
 
<p>
 
print(d1.Count);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">// 5</span></p>
 
<p>
 
print(d1.Keys);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> &nbsp; // {key_01,key_02,3,key_03,key01}</span></p>
 
<p>
 
print(d1.Values);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> // {value01,2222,{3333,string333},{happy,48,{funny,sad,88}},1111}</span></p>
 
<p>
 
print(d1.Remove(&quot;key_01&quot;));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// value01</span></p>
 
<p>
 
print(d1.Remove(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;">&nbsp; // {3333,string333}</span></p>
 
<p>
 
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;">&nbsp; // {&quot;key_02&quot;: 2222, &quot;key_03&quot;: {happy,48,{funny,sad,88}}, &quot;key01&quot;: 1111}</span></p>
 
<p>
 
&nbsp;</p>
 
<p>
 
&nbsp;</p>
 
<p>
 
&nbsp;</p>
 
  
 +
&nbsp;
 +
 +
<span style="color:#a52a2a;">'''Constructors'''</span>
 +
 +
*<span style="color:#000000;">'''()''' - Create a new dictionary with non-argument.</span>
 +
*<span style="color:#000000;">'''(Params&nbsp; AnyType)''' - Create new dictionary with the specified key-value pairs.</span>
 +
*<span style="color:#000000;">'''(array keys,&nbsp; array values)''' - Create new dictionary with the specified keys and values.</span>
 +
 +
&nbsp;<span style="color:#a52a2a;">'''Methods'''</span>
 +
 +
*<span style="color:#000000;">'''bool Add(string key, AnyType value)''' - Adds the specified key and value to the dictionary.</span>
 +
*<span style="color:#000000;">'''bool Add(number key, AnyType value)''' - Adds the specified key and value to the dictionary.</span>
 +
*<span style="color:#000000;">'''Empty set_Item(string key, AnyType value)''' - Set an item based on a key and a value.</span>
 +
*<span style="color:#000000;">'''Empty set_Item(number key, AnyType value)''' - Set an item based on a key and a value.</span>
 +
*<span style="color:#000000;">'''AnyType get_Item(string key)''' - Get an item based on a key.</span>
 +
*<span style="color:#000000;">'''AnyType get_Item(number key)''' - Get an item based on a key.</span>
 +
*<span style="color:#000000;">'''AnyType TryGetValue(string key)''' - Gets the value associated with the specified key.</span>
 +
*<span style="color:#000000;">'''AnyType TryGetValue(number key)''' - Gets the value associated with the specified key.</span>
 +
*<span style="color:#000000;">'''bool ContainsKey(string key)''' - Determines whether the dictionary contains the specified key.</span>
 +
*<span style="color:#000000;">'''bool ContainsKey(number key)''' - Determines whether the dictionary contains the specified key.</span>
 +
*<span style="color:#000000;">'''bool ContainsValue(AnyType value)''' - Determines whether the dictionary contains the specified value.</span>
 +
*<span style="color:#000000;">'''AnyType Remove(string key)''' - Remove the value with the specified key from the dictionary.</span>
 +
*<span style="color:#000000;">'''AnyType Remove(number key)''' - Remove the value with the specified key from the dictionary.</span>
 +
*<span style="color:#000000;">'''Empty Clear()''' - Remove all keys and values from the dictionary.</span>
 +
*<span style="color:#000000;">'''string ToString()''' - The string representation of the object.</span>
 +
 +
&nbsp;<span style="color:#a52a2a;">'''Properties'''</span>
 +
 +
*<span style="color:#000000;">'''number Count HasGetter'''&nbsp; - Gets the number of key/value pairs contained in the dictionary.</span>
 +
*<span style="color:#000000;">'''array Keys HasGetter'''&nbsp; - Gets a list of keys.</span>
 +
*<span style="color:#000000;">'''string ObjectTypeName HasGetter'''&nbsp; - The name of the type of object.</span>
 +
*<span style="color:#000000;">'''array SortedKeys HasGetter'''&nbsp; - Gets a list of keys sorted by current collation.</span>
 +
*<span style="color:#000000;">'''TypeInformation TypeInformation HasGetter'''&nbsp; - Get information about this class.</span>
 +
*<span style="color:#000000;">'''array Values HasGetter'''&nbsp; - Gets a list of values.</span>
 +
 +
&nbsp;
 +
 +
<span style="color:#a52a2a;">'''Examples'''</span>
 +
 +
&nbsp;
 +
 +
Dictionary d;
 +
 +
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; // {}</span>
 +
 +
&nbsp;
 +
 +
Dictionary d = new Dictionary();
 +
 +
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">&nbsp;&nbsp; // {}</span>
 +
 +
&nbsp;
 +
 +
Dictionary d = {"key1": 1, "key2": 2};
 +
 +
print(d);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// {"key1": 1, "key2": 2}</span>
 +
 +
&nbsp;
 +
 +
Dictionary d = {};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // Not work, will cause error.</span>
 +
 +
&nbsp;
 +
 +
Dictionary d1 = new Dictionary("key_01","value01");
 +
 +
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> //&nbsp; {"key_01": sdasd}</span>
 +
 +
print(d1.Add("key_02",2222));
 +
 +
print(d1.Add(3,"hello3333"));
 +
 +
print(d1.Add("key_03",{"happy",48,{"funny","sad",88}}));
 +
 +
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; {"3": hello3333, "key_01": value01, "key_02": 2222, "key_03": {happy,48,{funny,sad,88}}}</span>
 +
 +
print(d1.ContainsKey("key_01"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // true</span>
 +
 +
print(d1.ContainsKey(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> // true</span>
 +
 +
print(d1.ContainsKey("noexist"));&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">// false</span>
 +
 +
print(d1.ContainsValue("value01"));&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> // true</span>
 +
 +
print(d1.ContainsValue(2222));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#006400;">//&nbsp; true</span>
 +
 +
print(d1.ContainsValue({"happy",48,{"funny","sad",88}}));&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// true</span>
 +
 +
print(d1.get_Item("key_01"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<span style="color:#006400;"> // value01</span>
 +
 +
print(d1.get_Item(3)); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp; // hello3333</span>
 +
 +
print(d1.set_Item("key01",1111));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 +
 +
print(d1.set_Item(3,{3333,"string333"}));
 +
 +
print(d1.TryGetValue("key_01"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;"> // value01</span>
 +
 +
print(d1.TryGetValue(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <span style="color:#006400;">// {3333,"string333"}</span>
 +
 +
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#006400;">&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; {"3": {3333,string333}, "key_01": value01, "key_02": 2222, "key_03": {happy,48,{funny,sad,88}}, "key01": 1111}</span>
 +
 +
print(d1.Count);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#006400;">// 5</span>
 +
 +
print(d1.Keys);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color:#006400;"> &nbsp; // {key_01,key_02,3,key_03,key01}</span>
 +
 +
print(d1.Values);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;"> // {value01,2222,{3333,string333},{happy,48,{funny,sad,88}},1111}</span>
 +
 +
print(d1.Remove("key_01"));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006400;">// value01</span>
 +
 +
print(d1.Remove(3));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;">&nbsp; // {3333,string333}</span>
 +
 +
print(d1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006400;">&nbsp; // {"key_02": 2222, "key_03": {happy,48,{funny,sad,88}}, "key01": 1111}</span>
 +
 +
&nbsp;
 +
 +
&nbsp;
 +
 +
&nbsp;
  
 
[[Category:Data_Types_Literals_and_Variables]]
 
[[Category:Data_Types_Literals_and_Variables]]

Revision as of 04:42, 14 September 2011

Dictionary : The dictionary object

 

Constructors

  • () - Create a new dictionary with non-argument.
  • (Params  AnyType) - Create new dictionary with the specified key-value pairs.
  • (array keys,  array values) - Create new dictionary with the specified keys and values.

 Methods

  • bool Add(string key, AnyType value) - Adds the specified key and value to the dictionary.
  • bool Add(number key, AnyType value) - Adds the specified key and value to the dictionary.
  • Empty set_Item(string key, AnyType value) - Set an item based on a key and a value.
  • Empty set_Item(number key, AnyType value) - Set an item based on a key and a value.
  • AnyType get_Item(string key) - Get an item based on a key.
  • AnyType get_Item(number key) - Get an item based on a key.
  • AnyType TryGetValue(string key) - Gets the value associated with the specified key.
  • AnyType TryGetValue(number key) - Gets the value associated with the specified key.
  • bool ContainsKey(string key) - Determines whether the dictionary contains the specified key.
  • bool ContainsKey(number key) - Determines whether the dictionary contains the specified key.
  • bool ContainsValue(AnyType value) - Determines whether the dictionary contains the specified value.
  • AnyType Remove(string key) - Remove the value with the specified key from the dictionary.
  • AnyType Remove(number key) - Remove the value with the specified key from the dictionary.
  • Empty Clear() - Remove all keys and values from the dictionary.
  • string ToString() - The string representation of the object.

 Properties

  • number Count HasGetter  - Gets the number of key/value pairs contained in the dictionary.
  • array Keys HasGetter  - Gets a list of keys.
  • string ObjectTypeName HasGetter  - The name of the type of object.
  • array SortedKeys HasGetter  - Gets a list of keys sorted by current collation.
  • TypeInformation TypeInformation HasGetter  - Get information about this class.
  • array Values HasGetter  - Gets a list of values.

 

Examples

 

Dictionary d;

print(d);                                                                                             // {}

 

Dictionary d = new Dictionary();

print(d);                                                                                            // {}

 

Dictionary d = {"key1": 1, "key2": 2};

print(d);                                                                                           // {"key1": 1, "key2": 2}

 

Dictionary d = {};                                                                            // Not work, will cause error.

 

Dictionary d1 = new Dictionary("key_01","value01");

print(d1);                                                                                        //  {"key_01": sdasd}

print(d1.Add("key_02",2222));

print(d1.Add(3,"hello3333"));

print(d1.Add("key_03",{"happy",48,{"funny","sad",88}}));

print(d1);                               //          {"3": hello3333, "key_01": value01, "key_02": 2222, "key_03": {happy,48,{funny,sad,88}}}

print(d1.ContainsKey("key_01"));                                                     // true

print(d1.ContainsKey(3));                                                                // true

print(d1.ContainsKey("noexist"));                                                     // false

print(d1.ContainsValue("value01"));                                                 // true

print(d1.ContainsValue(2222));                                                       //  true

print(d1.ContainsValue({"happy",48,{"funny","sad",88}}));               // true

print(d1.get_Item("key_01"));                                                        // value01

print(d1.get_Item(3));                                                                   // hello3333

print(d1.set_Item("key01",1111));     

print(d1.set_Item(3,{3333,"string333"}));

print(d1.TryGetValue("key_01"));                                                   // value01

print(d1.TryGetValue(3));                                                              // {3333,"string333"}

print(d1);             //     {"3": {3333,string333}, "key_01": value01, "key_02": 2222, "key_03": {happy,48,{funny,sad,88}}, "key01": 1111}

print(d1.Count);                                                                          // 5

print(d1.Keys);                                                                           // {key_01,key_02,3,key_03,key01}

print(d1.Values);                                                                        // {value01,2222,{3333,string333},{happy,48,{funny,sad,88}},1111}

print(d1.Remove("key_01"));                                                      // value01

print(d1.Remove(3));                                                                 // {3333,string333}

print(d1);                                                                                  // {"key_02": 2222, "key_03": {happy,48,{funny,sad,88}}, "key01": 1111}