-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs__algorithm__datasources__dictionary.md.js
More file actions
1 lines (1 loc) · 3 KB
/
docs__algorithm__datasources__dictionary.md.js
File metadata and controls
1 lines (1 loc) · 3 KB
1
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[5],{eKhP:function(e,n,a){"use strict";a.r(n);var t=a("q1tI"),o=a.n(t),l=a("dEAq"),c=a("H1Ra"),r=o.a.memo((e=>{e.demos;return o.a.createElement(o.a.Fragment,null,o.a.createElement("div",{className:"markdown"},o.a.createElement("h2",{id:"\u5b57\u5178\u7684\u6982\u5ff5\u548c\u7528\u9014"},o.a.createElement(l["AnchorLink"],{to:"#\u5b57\u5178\u7684\u6982\u5ff5\u548c\u7528\u9014","aria-hidden":"true",tabIndex:-1},o.a.createElement("span",{className:"icon icon-link"})),"\u5b57\u5178\u7684\u6982\u5ff5\u548c\u7528\u9014"),o.a.createElement("ul",null,o.a.createElement("li",null,"\u5b57\u5178\u662f\u4e00\u79cd\u952e-\u503c\u961f\u5f62\u5f0f\u5b58\u50a8\u7684"),o.a.createElement("li",null,"\u5b57\u5178\u5c31\u50cf\u6211\u4eec\u7684\u7535\u8bdd\u53f7\u7801\u7c3f\u4e00\u6837\uff0c\u8981\u627e\u4e00\u4e2a\u7535\u8bdd\u65f6\uff0c\u540d\u5b57\u627e\u5230\u4e86\u7535\u8bdd\u53f7\u7801\u4e5f\u5c31\u627e\u5230\u4e86"),o.a.createElement("li",null,o.a.createElement("code",null,"javascript"),"\u7684",o.a.createElement("code",null,"object"),"\u7c7b\u5c31\u662f\u4ee5\u5b57\u5178\u7684\u5f62\u5f0f\u8bbe\u8ba1\u7684\uff0c\u6211\u4eec\u8981\u5b9e\u73b0\u4e00\u4e2a",o.a.createElement("code",null,"Dictionary"),"\u7c7b,\u8fd9\u6837\u4f1a\u6bd4 Object \u65b9\u4fbf\u6bd4\u5982\u663e\u793a\u5b57\u5178\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u5bf9\u5c5e\u6027\u8fdb\u884c\u6392\u5e8f\u7b49")),o.a.createElement("h2",{id:"\u4ee3\u7801\u5b9e\u73b0"},o.a.createElement(l["AnchorLink"],{to:"#\u4ee3\u7801\u5b9e\u73b0","aria-hidden":"true",tabIndex:-1},o.a.createElement("span",{className:"icon icon-link"})),"\u4ee3\u7801\u5b9e\u73b0"),o.a.createElement(c["a"],{code:"/**\n * \u5b57\u5178\n */\nfunction Dictonary() {\n this.dataStore = new Array();\n this.add = add;\n this.find = find;\n this.count = count;\n this.clear = clear;\n this.remove = remove;\n this.showAll = showAll;\n}\nfunction add(key, value) {\n this.dataStore[key] = value;\n}\nfunction find(key) {\n return this.dataStore[key];\n}\nfunction remove(key) {\n delete this.dataStore[key];\n}\nfunction showAll() {\n var dataKeys = Object.keys(this.dataStore);\n for (var keys in dataKeys) {\n console.log(dataKeys[keys] + '----' + this.dataStore[dataKeys[keys]]);\n }\n}\n\nfunction count() {\n return Object.keys(this.dataStore).length;\n}\n\nfunction clear() {\n var dataKeys = Object.keys(this.dataStore);\n for (var keys in dataKeys) {\n delete this.dataKeys[dataKeys[keys]];\n }\n}\n\nvar pbook = new Dictonary();\npbook.add('addadis', 200);\npbook.add('niki', 999);\npbook.add('NB', 645);\nconsole.log(pbook.find('niki'));\nconsole.log(pbook.showAll());\nconsole.log('--------');\npbook.remove('niki');\nconsole.log(pbook.showAll());",lang:"js"})))}));n["default"]=e=>{var n=o.a.useContext(l["context"]),a=n.demos;return o.a.useEffect((()=>{var n;null!==e&&void 0!==e&&null!==(n=e.location)&&void 0!==n&&n.hash&&l["AnchorLink"].scrollToAnchor(decodeURIComponent(e.location.hash.slice(1)))}),[]),o.a.createElement(r,{demos:a})}}}]);