{"id":549,"date":"2023-01-31T22:14:28","date_gmt":"2023-01-31T14:14:28","guid":{"rendered":"http:\/\/gjweb.top\/?p=549"},"modified":"2023-01-31T22:14:29","modified_gmt":"2023-01-31T14:14:29","slug":"02-list-str-set-map%e5%b8%b8%e7%94%a8%e7%9a%84api","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=549","title":{"rendered":"02. List &#038; str &#038; Set &#038; Map\u5e38\u7528\u7684API"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u5c5e\u6027\">\u5c5e\u6027<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"length-\u957f\u5ea6\">length \u957f\u5ea6<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"isempty-\u5224\u65ad\u662f\u5426\u4e3a\u7a7a\">isEmpty \u5224\u65ad\u662f\u5426\u4e3a\u7a7a<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"isnotempty-\u5224\u65ad\u662f\u5426\u4e0d\u4e3a\u7a7a\">isNotEmpty \u5224\u65ad\u662f\u5426\u4e0d\u4e3a\u7a7a<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"reversed-\u6570\u7ec4\u53cd\u8f6c\">reversed \u6570\u7ec4\u53cd\u8f6c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>var list = &#91;1,2,3,4,5]<br>list.length \/\/ 5;<br>list.isEmpty \/\/false<br>list.isNotEmpty \/\/ true<br>var newList = list.reversed().toList() \/\/ reversed \u7ffb\u8f6c\u7684\u6570\u7ec4\u662f(...)\u5f62\u5f0f\u7684,\u9700\u8981\u8c03\u7528 toList \u8fdb\u884c\u8f6c\u6362<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u65b9\u6cd5\">\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-add-\u6dfb\u52a0\u6570\u7ec4\">arr.add \u6dfb\u52a0\u6570\u7ec4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.add(\"zhangsan\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-addall-\u6dfb\u52a0\u591a\u4e2a\">arr.addAll \u6dfb\u52a0\u591a\u4e2a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.addAll(&#91;\"xxx\",\"vvv\"])<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-indexof-\u67e5\u627e-\u540c-js-\u7684\u65b9\u6cd5\">arr.indexof \u67e5\u627e (\u540c JS \u7684\u65b9\u6cd5)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.indexOf(\"xxx\") \/\/ 1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-remove-\u5220\u9664-\u5177\u4f53\u503c\">arr.remove \u5220\u9664(\u5177\u4f53\u503c)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.remove(\"xxx\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-removeat-\u5220\u9664-\u4e0b\u6807\">arr.removeAt \u5220\u9664 (\u4e0b\u6807)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.removeAt(0)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-fillrange-\u4fee\u6539\">arr.fillRange \u4fee\u6539<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list,fillRange(\u5f00\u59cbindex,\u7ed3\u675f\u7684index,\u66ff\u6362\u7684\u503c)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-insert-\u63d2\u5165\u4e00\u4e2a\">arr.insert \u63d2\u5165\u4e00\u4e2a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.insert(\u5f00\u59cbindex,\u7ed3\u675findex,\u63d2\u5165\u7684\u5185\u5bb9)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-insertall-\u63d2\u5165\u591a\u4e2a\">arr.insertAll \u63d2\u5165\u591a\u4e2a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.insertAll(\u5f00\u59cbindex,\u7ed3\u675findex,&#91;'data1',\"data2\"])<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arr-join-\u8f6c\u5b57\u7b26\u4e32\">arr.join \u8f6c\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>list.join(\",\") \/\/ \u8f6c\u5b57\u7b26\u4e32\u4ee5\u9017\u53f7\u7684\u5f62\u5f0f (\u548cJS\u76f8\u540c)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"str-\u5b57\u7b26\u4e32\u8f6c-list\">Str \u5b57\u7b26\u4e32\u8f6c List<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>var str = \"hello\"<br>str.split(\",\") \/\/ &#91;h,e,l,l,o]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"set-\u7528\u6cd5\">Set \u7528\u6cd5<\/h2>\n\n\n\n<p>\u5e38\u7528\u4e8e\u505a List \u7684\u53bb\u91cd<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var set = new Set();<br>set.addAll(&#91;1,2,3,4,5,1]);<br>print(set.toList()); \/\/ &#91;1,2,3,4,5]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"map-\u7528\u6cd5\">Map \u7528\u6cd5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>var map = new Map();<br>map&#91;\"name\"] = \"zhangsam\";<br>map&#91;\"age\"] = 19;<br>map.keys \/\/ (name, age)<br>map.values \/\/ (zhangsan,19)<br>map.isEmpty \/\/ false<br>map.isNotEmpty \/\/ true<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"list-set-map-\u901a\u7528\u65b9\u6cd5\">List &amp; Set &amp; Map \u901a\u7528\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"foreach-\u540c-js-\u4e2d\u7684\u7528\u6cd5\u76f8\u540c\">forEach \u540c js \u4e2d\u7684\u7528\u6cd5\u76f8\u540c<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"map-\u540c-js-\u7528\u6cd5\">map \u540c js \u7528\u6cd5<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"where-\u540c-js-\u7684-fill-\u65b9\u6cd5\">where \u540c js \u7684 fill \u65b9\u6cd5<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"any-\u5224\u65ad\u53ea\u8981\u96c6\u5408\u4e2d\u6709\u4e00\u4e2a\u6ee1\u8db3\u5c31\u662f-true\">any \/\/ \u5224\u65ad\u53ea\u8981\u96c6\u5408\u4e2d\u6709\u4e00\u4e2a\u6ee1\u8db3\u5c31\u662f true<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"every-\u5224\u65ad\u96c6\u5408\u6bcf\u4e2a\u90fd\u6ee1\u8db3\u624d\u8fd4\u56de-true\">every \/\/ \u5224\u65ad\u96c6\u5408\u6bcf\u4e2a\u90fd\u6ee1\u8db3\u624d\u8fd4\u56de true<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u5c5e\u6027 length \u957f\u5ea6 isEmpty \u5224\u65ad\u662f\u5426\u4e3a\u7a7a isNotEmpty \u5224\u65ad\u662f\u5426\u4e0d\u4e3a\u7a7a reversed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-dart"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=549"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":550,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions\/550"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}