{"id":1392,"date":"2022-11-15T19:58:16","date_gmt":"2022-11-15T11:58:16","guid":{"rendered":"http:\/\/175.24.184.226\/?p=1392"},"modified":"2022-11-15T19:58:16","modified_gmt":"2022-11-15T11:58:16","slug":"golang%e8%af%ad%e8%a8%80map%e5%85%a8%e6%96%b9%e4%bd%8d%e4%bb%8b%e7%bb%8d-2","status":"publish","type":"post","link":"\/?p=1392","title":{"rendered":"golang\u8bed\u8a00map\u5168\u65b9\u4f4d\u4ecb\u7ecd"},"content":{"rendered":"<h2>\u4e00\u3001map\u7684\u4ecb\u7ecd<\/h2>\n<h3>1.\u57fa\u672c\u4ecb\u7ecd<\/h3>\n<p>map \u662f key-value \u6570\u636e\u7ed3\u6784\uff0c\u53c8\u79f0\u4e3a\u5b57\u6bb5\u6216\u8005\u5173\u8054\u6570\u7ec4\u3002\u7c7b\u4f3c\u5176\u5b83\u7f16\u7a0b\u8bed\u8a00\u7684\u96c6\u5408\uff0c \u5728\u7f16\u7a0b\u4e2d\u662f\u7ecf\u5e38\u4f7f\u7528\u5230<\/p>\n<h3>2.\u58f0\u660e\u57fa\u672c\u8bed\u6cd5<\/h3>\n<p>var map \u53d8\u91cf\u540d map[keytype]valuetype<\/p>\n<ul>\n<li><strong>key \u53ef\u4ee5\u662f\u4ec0\u4e48\u7c7b\u578b :<\/strong>golang \u4e2d\u7684 map\uff0c\u7684 key \u53ef\u4ee5\u662f\u5f88\u591a\u79cd\u7c7b\u578b\uff0c\u6bd4\u5982 bool, \u6570\u5b57\uff0cstring, \u6307\u9488, channel , \u8fd8\u53ef\u4ee5\u662f\u53ea \u5305\u542b\u524d\u9762\u51e0\u4e2a\u7c7b\u578b\u7684 \u63a5\u53e3, \u7ed3\u6784\u4f53, \u6570\u7ec4<\/li>\n<li><strong>\u901a\u5e38 key \u4e3a int \u3001string     \u6ce8\u610f: slice\uff0c map \u8fd8\u6709 function \u4e0d\u53ef\u4ee5\uff0c\u56e0\u4e3a\u8fd9\u51e0\u4e2a\u6ca1\u6cd5\u7528 == \u6765\u5224\u65ad<\/strong> <\/li>\n<li><strong>valuetype \u53ef\u4ee5\u662f\u4ec0\u4e48\u7c7b\u578b:<\/strong> valuetype \u7684\u7c7b\u578b\u548c key \u57fa\u672c\u4e00\u6837\uff0c\u8fd9\u91cc\u6211\u5c31\u4e0d\u518d\u8d58\u8ff0\u4e86 \u901a\u5e38\u4e3a: \u6570\u5b57(\u6574\u6570,\u6d6e\u70b9\u6570),string,map,struct<\/li>\n<\/ul>\n<p>3.\u58f0\u660e\u7684\u4e3e\u4f8b<\/p>\n<p><strong>map \u58f0\u660e\u7684\u4e3e\u4f8b\uff1a<\/strong><\/p>\n<ul>\n<li>var a map[string]string<\/li>\n<li>var a map[string]int<\/li>\n<li>var a map[int]string<\/li>\n<li>var a map[string]map[string]string<\/li>\n<li>\u6ce8\u610f\uff1a\u58f0\u660e\u662f\u4e0d\u4f1a\u5206\u914d\u5185\u5b58\u7684\uff0c\u521d\u59cb\u5316\u9700\u8981 make \uff0c\u5206\u914d\u5185\u5b58\u540e\u624d\u80fd\u8d4b\u503c\u548c\u4f7f\u7528 <\/li>\n<\/ul>\n<pre><code class=\"language-go\">package main\nimport (\n    &quot;fmt&quot;\n)  \nfunc main(){\n    \/\/map\u7684\u58f0\u660e\u6ce8\u610f\u4e8b\u9879\n    var a map[string]string\n    \/\/ \u5728\u4f7f\u7528map\u524d\uff0c\u9996\u5148\u8981make \u5206\u914d\u6570\u636e\u7a7a\u95f4\u3002\n    a = make(map[string]string,10)\n    a[&quot;no1&quot;] = &quot;\u677e\u6c5f&quot;\n    a[&quot;no2&quot;] = &quot;\u5434\u7528&quot;\n    a[&quot;no3&quot;] = &quot;\u6b66\u677e&quot;\n    a[&quot;no1&quot;] = &quot;\u5434\u7528&quot;\n    fmt.Println(a)\n}<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151552984.jpeg\" alt=\"\" \/><\/p>\n<blockquote>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<p><strong>1.\u5728\u4f7f\u7528\u524d\u5fc5\u987bmake \u5426\u5219\u7f16\u8bd1\u4e0d\u901a\u8fc7\uff0c\u56e0\u4e3a\u6ca1\u6709\u7a7a\u95f4\uff0c\u6240\u4ee5\u5fc5\u987b\u5148\u7533\u8bf7\u7a7a\u95f4<\/strong><\/p>\n<p><strong>2.\u4e0a\u9762\u7684\u4ee3\u7801\u548c\u7ed3\u679c\u8bf4\u660e\u4e86map\u4e2d  key\u503c\u662f\u4e0d\u53ef\u4ee5\u91cd\u590d\u7684\uff0c\uff08\u82e5\u91cd\u590d\u4e86\u4ee5\u6700\u540e\u4e00\u4e2akey-value\u4e3a\u4e3b\uff09value\u503c\u53ef\u4ee5\u91cd\u590d<\/strong><\/p>\n<\/blockquote>\n<p><strong>make\u5185\u7f6e\u51fd\u6570<\/strong><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151553536.jpeg\" alt=\"\" \/><\/p>\n<h2>\u4e8c\u3001map \u7684\u4f7f\u7528<\/h2>\n<h3>1.map\u58f0\u660e\u4e09\u79cd\u65b9\u5f0f<\/h3>\n<p><strong>\u65b9\u5f0f1\uff1a<\/strong><\/p>\n<pre><code class=\"language-go\">var a map[string]string\n\/\/ \u5728\u4f7f\u7528map\u524d\uff0c\u9996\u5148\u8981make \u5206\u914d\u6570\u636e\u7a7a\u95f4\u3002\na = make(map[string]string,10)\na[&quot;no3&quot;] = &quot;\u677e\u6c5f&quot;\na[&quot;no1&quot;] = &quot;\u5434\u7528&quot;\na[&quot;no3&quot;] = &quot;\u6b66\u677e&quot;\na[&quot;no2&quot;] = &quot;\u5434\u7528&quot;\nfmt.Println(a)<\/code><\/pre>\n<p><strong>\u65b9\u5f0f2\uff1a<\/strong><\/p>\n<pre><code class=\"language-go\">\/\/\u7b2c\u4e8c\u79cd\u65b9\u5f0f\ncities := make(map[string]string)\ncities[&quot;no1&quot;] = &quot;\u4e0a\u6d77&quot;\ncities[&quot;no2&quot;] = &quot;\u897f\u5b89&quot;\ncities[&quot;no3&quot;] = &quot;\u5929\u6d25&quot;\nfmt.Println(cities)<\/code><\/pre>\n<p><strong>\u65b9\u5f0f3\uff1a<\/strong><\/p>\n<pre><code class=\"language-go\">\/\/\u7b2c\u4e09\u79cd\u65b9\u5f0f\nheroes := map[string]string{\n    &quot;no1&quot; : &quot;chengdu&quot;,    \/\/ \u6ce8\u610f\u4e0d\u80fd\u5c11\u4e86,\u53f7\n    &quot;no2&quot; : &quot;beijing&quot;,\n    &quot;no3&quot; : &quot;wuhan&quot;,\n}\nfmt.Println(heroes)<\/code><\/pre>\n<h3>2.map[string]map[string]string\u4f7f\u7528\u6848\u4f8b<\/h3>\n<ul>\n<li>\u6f14\u793a\u4e00\u4e2a key-value \u7684 value \u662f map \u7684\u6848\u4f8b<\/li>\n<li>\u6bd4\u5982\uff1a\u6211\u4eec\u8981\u5b58\u653e 3 \u4e2a\u5b66\u751f\u4fe1\u606f, \u6bcf\u4e2a\u5b66\u751f\u6709 name \u548c sex \u4fe1\u606f<\/li>\n<li>\u601d\u8def: <code>map\\[string\\]map\\[string\\]string<\/code><\/li>\n<\/ul>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151555537.jpeg\" alt=\"\" \/><\/p>\n<h2>\u4e09\u3001map \u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c<\/h2>\n<h3>1.map \u589e\u52a0\u548c\u66f4\u65b0<\/h3>\n<p><strong>map[&quot;key&quot;] = value \/\/\u5982\u679c key \u8fd8\u6ca1\u6709\uff0c\u5c31\u662f\u589e\u52a0\uff0c\u5982\u679c key \u5b58\u5728\u5c31\u662f\u4fee\u6539<\/strong><\/p>\n<pre><code class=\"language-go\">cities := make(map\\[string\\]string)\ncities[&quot;no1&quot;] = &quot;\u4e0a\u6d77&quot;\ncities[&quot;no2&quot;] = &quot;\u897f\u5b89&quot;\ncities[&quot;no3&quot;] = &quot;\u5929\u6d25&quot;\nfmt.Println(cities)\n\/\/\u56e0\u4e3ano3 \u8fd9\u4e2akey\u503c\u5df2\u7ecf\u5b58\u5728\uff0c\u6240\u4ee5\u4e0b\u9762\u7684\u5c31\u662f\u4fee\u6539\uff0c\u82e5\u65e0\u5c31\u662f\u589e\u52a0\ncities[&quot;no3&quot;] = &quot;\u5929\u6d25...&quot;\nfmt.Println(cities)<\/code><\/pre>\n<h3>2.map \u5220\u9664<\/h3>\n<p><code>delete(map\uff0c&quot;key&quot;)<\/code> \uff0c<strong>delete \u662f\u4e00\u4e2a\u5185\u7f6e\u51fd\u6570\uff0c\u5982\u679c key \u5b58\u5728\uff0c\u5c31\u5220\u9664\u8be5 key-value,\u5982\u679c key \u4e0d\u5b58\u5728\uff0c \u4e0d\u64cd\u4f5c\uff0c\u4f46\u662f\u4e5f\u4e0d\u4f1a\u62a5\u9519<\/strong><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151556466.jpeg\" alt=\"\" \/><\/p>\n<pre><code class=\"language-go\">\/\/\u5220\u9664\u6f14\u793a\ndelete(cities,&quot;no1&quot;)\nfmt.Println(cities)\n\/\/\u5f53delete\u6307\u5b9a\u7684key\u4e0d\u5b58\u5728\u65f6\uff0c\u5220\u9664\u4e0d\u64cd\u4f5c\uff0c\u4e5f\u4e0d\u4f1a\u62a5\u9519\ndelete(cities,&quot;no4&quot;)\nfmt.Println(cities)<\/code><\/pre>\n<p>\u5982\u679c\u6211\u4eec\u8981\u5220\u9664 map \u7684\u6240\u6709 key ,\u6ca1\u6709\u4e00\u4e2a\u4e13\u95e8\u7684\u65b9\u6cd5\u4e00\u6b21\u5220\u9664\uff0c\u53ef\u4ee5\u904d\u5386\u4e00\u4e0b key, \u9010\u4e2a\u5220\u9664 \u6216\u8005 <code>**map = make(...)<\/code>\uff0c<code>make<\/code> \u4e00\u4e2a\u65b0\u7684\uff0c\u8ba9\u539f\u6765\u7684\u6210\u4e3a\u5783\u573e\uff0c\u88ab gc \u56de\u6536** <\/p>\n<p>\u6ce8\u610f\u5982\u679c\u8981\u5168\u90e8\u5220\u9664\uff0c\u4e24\u79cd\u65b9\u5f0f<\/p>\n<ul>\n<li>\u904d\u5386\u6240\u6709key\uff0c\u9010\u4e00\u5220\u9664\u76f4\u63a5<\/li>\n<li>make\u4e00\u4e2a\u65b0\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-go\">\/\/\u5982\u679c\u5e0c\u671b\u4e00\u6b21\u6027\u5220\u9664\u6240\u6709  \u4e24\u79cd\u65b9\u5f0f\n\/\/1.\u904d\u5386\u6240\u6709key\uff0c\u9010\u4e00\u5220\u9664\n\/\/2.\u76f4\u63a5make\u4e00\u4e2a\u65b0\u7a7a\u95f4\u3002\ncities := make(map[string]string)\nfmt.Println(cities)<\/code><\/pre>\n<h3>3.map \u67e5\u627e<\/h3>\n<pre><code class=\"language-go\">\/\/\u6f14\u793amap\u67e5\u627e\nval ok :=cities[&quot;no2&quot;]\nif ok{\nfmt.Printf(&quot;\u627e\u5230\u4e86  \u503c\u4e3a%v&quot;,val)\n}else{\nfmt.Printf(&quot;\u6ca1\u6709\u627e\u5230&quot;)\n}<\/code><\/pre>\n<p><strong>\u8bf4\u660e\uff1a\u5982\u679c cities \u8fd9\u4e2a map \u4e2d\u5b58\u5728 &quot;no2&quot; \uff0c \u90a3\u4e48 findRes \u5c31\u4f1a\u8fd4\u56de true,\u5426\u5219\u8fd4\u56de flase<\/strong><\/p>\n<h2>\u56db\u3001map\u7684\u5176\u4ed6\u64cd\u4f5c<\/h2>\n<h3>1.map \u904d\u5386\uff1a<\/h3>\n<p>\u6848\u4f8b\u6f14\u793a\u76f8\u5bf9\u590d\u6742\u7684 map \u904d\u5386\uff1a\u8be5 map \u7684 value \u53c8\u662f\u4e00\u4e2a map<\/p>\n<p>\u8bf4\u660e\uff1amap \u7684\u904d\u5386\u4f7f\u7528 for-range \u7684\u7ed3\u6784\u904d\u5386<\/p>\n<pre><code class=\"language-go\">package main\nimport (\n    &quot;fmt&quot;\n)  \nfunc main(){\n    cities := make(map[string]string)\n    cities[&quot;no1&quot;] = &quot;\u4e0a\u6d77&quot;\n    cities[&quot;no2&quot;] = &quot;\u897f\u5b89&quot;\n    cities[&quot;no3&quot;] = &quot;\u5929\u6d25&quot;\n    for k , v :=range cities{\n        fmt.Printf(&quot;k=%v v=%v \\n&quot;,k,v)\n    }\n}<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151557824.jpeg\" alt=\"\" \/><\/p>\n<p>\u590d\u6742\u904d\u5386\u6848\u4f8b<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151557851.jpeg\" alt=\"\" \/><\/p>\n<h3>2.map \u7684\u957f\u5ea6<\/h3>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151558780.jpeg\" alt=\"\" \/><\/p>\n<pre><code class=\"language-go\">package main\nimport (\n    &quot;fmt&quot;\n)  \nfunc main(){\n    cities := make(map[string]string)\n    cities[&quot;no1&quot;] = &quot;\u4e0a\u6d77&quot;\n    cities[&quot;no2&quot;] = &quot;\u897f\u5b89&quot;\n    cities[&quot;no3&quot;] = &quot;\u5929\u6d25&quot;\n    for k , v :=range cities{\n        fmt.Printf(&quot;k=%v v=%v \\n&quot;,k,v)\n    }\n    fmt.Println(len(cities))   \/\/3\n}<\/code><\/pre>\n<h3>3.map \u5207\u7247<\/h3>\n<h4>1.\u57fa\u672c\u4ecb\u7ecd<\/h4>\n<p>\u5207\u7247\u7684\u6570\u636e\u7c7b\u578b\u5982\u679c\u662f <code>map<\/code>\uff0c\u5219\u6211\u4eec\u79f0\u4e3a <code>slice of map<\/code>\uff0c<code>map<\/code> \u5207\u7247\uff0c\u8fd9\u6837\u4f7f\u7528\u5219<code> map<\/code> \u4e2a\u6570\u5c31\u53ef\u4ee5\u52a8 \u6001\u53d8\u5316\u4e86\u3002<\/p>\n<h4>2.\u6848\u4f8b<\/h4>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151558696.jpeg\" alt=\"\" \/><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151559728.jpeg\" alt=\"\" \/><\/p>\n<pre><code class=\"language-go\">package main\nimport (\n    &quot;fmt&quot;\n)  \nfunc main(){\n    monsters := make([]map[string]string,2)\n\n    if monsters[0] == nil{\n        monsters[0] = make(map[string]string,2)\n        monsters[0][&quot;name&quot;] = &quot;\u725b\u9b54\u738b&quot;\n        monsters[0][&quot;age&quot;] = &quot;500&quot;\n    }\n    if monsters[1] == nil{\n        monsters[1] = make(map[string]string,2)\n        monsters[1][&quot;name&quot;] = &quot;\u7389\u5154\u7cbe&quot;\n        monsters[1][&quot;age&quot;] = &quot;400&quot;\n    }\n    \/\/\u8fd9\u91cc\u5982\u679c\u6211\u4eec\u7ee7\u7eed\u4f7f\u7528monsters[2] \u80af\u5b9a\u8d8a\u754c  \u6240\u4ee5\u6211\u4eec\u9700\u8981\u52a8\u6001\u8ffd\u52a0\n    \/\/\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u4f7f\u7528\u5207\u7247\u7684append\u51fd\u6570\uff0c\u53ef\u4ee5\u589e\u52a0monsters\n    \/\/\u6f14\u793a\uff1a\n    newMonsters := map[string]string{\n        &quot;name&quot; : &quot;\u706b\u4e91\u90aa\u795e&quot;,\n        &quot;age&quot;  : &quot;200&quot;,\n    }\n    \/\/\u8ffd\u52a0\n    monsters = append(monsters,newMonsters)\n    fmt.Println(monsters)\n}<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151601406.jpeg\" alt=\"\" \/><\/p>\n<h3>4.map \u6392\u5e8f<\/h3>\n<h4>1.\u57fa\u672c\u4ecb\u7ecd<\/h4>\n<ul>\n<li>golang \u4e2d\u6ca1\u6709\u4e00\u4e2a\u4e13\u95e8\u7684\u65b9\u6cd5\u9488\u5bf9 map \u7684 key \u8fdb\u884c\u6392\u5e8f<\/li>\n<li>golang \u4e2d\u7684 map \u9ed8\u8ba4\u662f\u65e0\u5e8f\u7684\uff0c\u6ce8\u610f\u4e5f\u4e0d\u662f\u6309\u7167\u6dfb\u52a0\u7684\u987a\u5e8f\u5b58\u653e\u7684\uff0c\u4f60\u6bcf\u6b21\u904d\u5386\uff0c\u5f97\u5230\u7684\u8f93\u51fa \u53ef\u80fd\u4e0d\u4e00\u6837<\/li>\n<li>golang \u4e2d map \u7684\u6392\u5e8f\uff0c\u662f\u5148\u5c06 key \u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u6839\u636e key \u503c\u904d<\/li>\n<\/ul>\n<h4>2.\u6848\u4f8b\u6f14\u793a<\/h4>\n<pre><code class=\"language-go\">    map1 := make(map[int]int,100)\n    map1[10] = 100\n    map1[1] = 13\n    map1[4] = 56\n    map1[8] = 90\n    for k , v :=range map1{\n        fmt.Printf(&quot;k=%v  v=%v  \\n&quot;,k , v)  \/\/\u65e0\u5e8f\u7684\n    }<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151601907.jpeg\" alt=\"\" \/><\/p>\n<p>\u6ca1\u6709\u6392\u5e8f  \u4e0b\u6765\u8fdb\u884c\u6392\u5e8f<\/p>\n<pre><code class=\"language-go\">\/\/\u5982\u679c\u6309\u7167map\u7684key\u7684\u987a\u5e8f\u8fdb\u884c\u6392\u5e8f\u8f93\u51fa\n\/\/1. \u5148\u5c06map\u7684key  \u653e\u5165\u5230\u5207\u7247\u4e2d\n\/\/2.\u5bf9\u5207\u7247\u6392\u5e8f\n\/\/3. \u904d\u5386\u5207\u7247\uff0c\u7136\u540e\u6309\u7167key\u6765\u8f93\u51famap\u7684\u503c\nvar keys[]int \nfor k , _ := range map1{\n    keys = append(keys,k)\n}\n\/\/\u6392\u5e8f\nsort.Ints(keys)\nfmt.Println(keys)  \/\/\u8f93\u51fakey\u503c\n\nfor _ , k :=range keys{\n    fmt.Printf(&quot;map1[%v]=%v \\n&quot;,k,map1[k])\n}<\/code><\/pre>\n<h2>\u4e94\u3001map \u4f7f\u7528\u7ec6\u8282<\/h2>\n<p>1) <strong>map \u662f\u5f15\u7528\u7c7b\u578b\uff0c\u9075\u5b88\u5f15\u7528\u7c7b\u578b\u4f20\u9012\u7684\u673a\u5236\uff0c\u5728\u4e00\u4e2a\u51fd\u6570\u63a5\u6536 map\uff0c\u4fee\u6539\u540e\uff0c\u4f1a\u76f4\u63a5\u4fee\u6539\u539f\u6765 \u7684 map<\/strong> <\/p>\n<pre><code class=\"language-go\">package main\nimport (\n    &quot;fmt&quot;\n)  \nfunc modify(map2 map[int]int){\n    map2[10] = 900\n}\n\nfunc main(){\n    \/\/map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u9075\u5b88\u5f15\u7528\u7c7b\u578b\u4f20\u9012\u673a\u5236\uff0c\u5728\u4e00\u4e2a\u51fd\u6570\u63a5\u53d7map\n    \/\/\u4fee\u6539\u540e\uff0c\u4f1a\u76f4\u63a5\u4fee\u6539\u539f\u6765\u7684map\n    map1 := make(map[int]int)\n    map1[1] = 90\n    map1[2] = 88\n    map1[10] = 1\n    map1[20] = 2\n\n    modify(map1)\n    fmt. Println(map1) \n}<\/code><\/pre>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151604068.jpeg\" alt=\"\" \/><\/p>\n<p>2) <strong>map \u7684\u5bb9\u91cf\u8fbe\u5230\u540e\uff0c\u518d\u60f3 map \u589e\u52a0\u5143\u7d20\uff0c\u4f1a\u81ea\u52a8\u6269\u5bb9<\/strong>\uff0c\u5e76\u4e0d\u4f1a\u53d1\u751f panic\uff0c\u4e5f\u5c31\u662f\u8bf4 map \u80fd\u52a8 \u6001\u7684\u589e\u957f \u952e\u503c\u5bf9(key-value\uff09<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151604235.jpeg\" alt=\"\" \/><\/p>\n<p>3) <strong>map \u7684 value \u4e5f\u7ecf\u5e38\u4f7f\u7528 struct \u7c7b\u578b\uff0c\u66f4\u9002\u5408\u7ba1\u7406\u590d\u6742\u7684\u6570\u636e<\/strong>(\u6bd4\u524d\u9762 value\u662f\u4e00\u4e2a map \u66f4\u597d\uff09<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/202211151604295.jpeg\" alt=\"\" \/><\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u4ee5\u4e0a\u662fmap\u7684\u4e00\u4e9b\u4ecb\u7ecd \u4ecemap\u7684\u5b9a\u4e49\u5230\u4e00\u4e9b\u589e\u5220\u67e5\u6539\u7684\u64cd\u4f5c\uff0c\u518d\u5230\u4e00\u4e9b\u4f7f\u7528\u4e0a\u7684\u7ec6\u8282\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001map\u7684\u4ecb\u7ecd 1.\u57fa\u672c\u4ecb\u7ecd map \u662f key-value \u6570\u636e\u7ed3\u6784\uff0c\u53c8\u79f0\u4e3a\u5b57\u6bb5\u6216\u8005\u5173\u8054\u6570\u7ec4\u3002\u7c7b\u4f3c\u5176\u5b83\u7f16\u7a0b\u8bed\u8a00\u7684\u96c6\u5408\uff0c \u5728\u7f16\u7a0b\u4e2d\u662f\u7ecf   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[117],"tags":[113,114],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1392"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1392"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1392\/revisions"}],"predecessor-version":[{"id":1393,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1392\/revisions\/1393"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1392"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}