js字典算法
来源:互联网 发布:淘宝直播主播怎么收费 编辑:程序博客网 时间:2024/05/16 08:14
var Dict = function () { this.items = [];//用于保存项目};/* * method 添加 * parameter key,value * */Dict.prototype.add = function (key, value) { this.items[key] = value;};/** method 查找* parameter key* */Dict.prototype.find = function (key) { return this.items[key];};/* * method 移除 * parameter key * */Dict.prototype.remove = function (key) { delete this.items[key];};/* * method 查找 * parameter key * */Dict.prototype.display = function () { for (var key in this.items) { console.log(key + ' -> ' + this.items[key]); }};/* * method 数量 * parameter * */Dict.prototype.count = function () { var count = 0; for (var key in this.items) { count++; } return count;};/* * method 清楚 * parameter key * */Dict.prototype.clear = function () { this.items = [];};/*----------------------------------------examples------------------------------------*/if (!module.parent) { var d = new Dict(); d.add('me', 'Ralph-Wang'); d.add('age', 25); d.add('job', 'SDT'); d.display(); console.log(d.count());}
0 0
- js字典算法
- JS数据结构与算法--字典
- js数据结构与算法——集合,字典,哈希
- js读取cookie字典
- 《JS语法字典》
- 《JS语法字典》
- js语法字典
- JS语法字典
- 《JS语法字典》
- JS语法字典
- JS语法字典
- JS语法字典
- JS语法字典
- js语法字典
- JS语法字典
- JS数组,字典
- js数据结构和算法(五)字典和散列(hash)
- 字典排序算法
- 改变TextView里面某部分字体的颜色、大小、样式等属性
- 自己写的HTTP服务器与muduo库对比——找出代码中的不足
- inux编程下signal()函数
- 【一天一道LeetCode】#125. Valid Palindrome
- leetcode 373. Find K Pairs with Smallest Sums
- js字典算法
- java的重载、覆盖、隐藏
- 计蒜客 微软项目经理的挑选方案
- http://codeforces.com/gym/100803/attachments A题 Bit String Reordering
- html实现全屏分页
- PHP API接口调用跨域问题
- 架构设计:系统间通信(3)——IO通信模型和JAVA实践 上篇
- HTML5混编学习笔记:Boxing Model、Selector、specificity、float/postion
- eclipse在ubuntu16.04新建工程和新建class卡死