Silk Dictionary

Dictionary is a sorted container that contains key-value pairs with unique keys. 
A pair of braces will create an empty dictionary, and a comma-separated list of key:value pairs within the braces will add initial key:value pairs to the dictionary.
dict={};
dict={1:"Gu"2:"Zhang","city":"Shanghai"};
key-value pair is accessed by placing the key within square brackets after the name of the dictionary:
print(dict[1]);
print(dict["city"]);
If the key is not existing in dictionary, will get undefined error:
print(dict["age"]);//undefined 

The key and value in dictionary can be of any data type, but the key must be unique, if there are duplicate keys in initial list, the key-value pair will be the last one.
dict={"name":"Gu"2:"Zhang","3":true2:"good"};
print(dict[2]);//the reulst is "good"
Like Array, dictionary/array in dictionary is allowed, and the key can also be dictionary/array:
array=["good","OK"];
dict={"name":"Wang""detail":array, "age":10, array:"OK","ID":[1,2,3]};
print(dict["detail"][0]);

The value of a key-value pair can be fetched by placing the key within square brackets after the name of the dictionary:
print(dict["name"]);

Dictionary cannot be accessed by index, to loop through the dictionary, we need to use a group of functions(begin, end, next, get):
dict={"name":"Wang""age":10"score":85.5};
for(i=dict.begin();!dict.end(i);dict.next(i))
   print(dict.get(i)[0],dict.get(i)[1]);
   
The result is as follows:
age 10
name Wang
score 85.500000

begin() will return an iterator to the first element of the dictionary; end(i) is used to check if the iterator is pointing to the end of the dictionary, if yes, it will return 1; next(i) will move the iterator to the next element; get(i) will get the key-value by using the iterator.

Member functions:

find(key)
 Find a key-value pair with key equivalent to key, and return the value, if the item is not found, it will return null.
dict={"name":"Wang""detail":array, "age":10};
value=dict.find("age");
print(value);

insert(key,value)
 Insert a key-value pair, and return 1 if the item is inserted, otherwise it will return 0; if the key is existing, the insertion will fail.
dict={"name":"Wang""age":10};
dict.insert("year",2020);
for(i=dict.begin();!dict.end(i);dict.next(i))
    print(dict.get(i)[0],dict.get(i)[1]);
You can also place the key within square brackets and place the value at the right side to insert key-value pair:
dict["year"]=2010;//In this way, if the key is existing, the value will be updated, it's different with insert.

clear()

 Clear all the elements(key-value pairs) in dictionary.
dict={"name":"Wang""age":10};
dict.clear();

erase(key)

 Remove the element(key-value pair) with the key. it will return 1 if the element is removed, otherwise it will return 0.
erase(iter)
 Remove the element(key-value pair) at the position of iter. it will return the next iterator if the element is removed.
 For the reverse iterator, it will return the previous iterator.
dict={"name":"Wang""detail":array, "age":10, array:"OK"};
result=dict.erase("age");
for(i=dict.begin();!dict.end(i);dict.next(i))
    print(dict.get(i)[0],dict.get(i)[1]);

get(key)

 Get the element with the key, if the element is found, return an array which has the key-value pair, otherwise it will return null.
dict={"name":"Wang""detail":"a good man""age":20"phone":"13799999999"};
ret=dict.get("age");
if(ret)
   print(ret[0],"=",ret[1]);

get(iter)

 Get the element with the iterator, if the element is found, return an array which has the key-value pair, otherwise it will return null.
dict={"name":"Wang""detail":"a good man""age":20"phone":"13799999999"};
for(iter=dict.begin();!dict.end(iter);dict.next(iter))
{
    ret=dict.get(iter);
    print(ret[0],"=",ret[1]);
}    

begin()
Return an iterator to the first element of the dictionary.

end(iter)
Check if the iterator is pointing to the end of the dictionary, if yes, it will return 1.

next(iter)
Move the iterator to the next element.

rbegin()
Return an reverse iterator to the first element of the reversed dictionary(the last element of the dictionary).

rend(iter)
Check if the iterator is pointing to the end of the reversed dictionary(the first element of the dictionary), if yes, it will return 1.