数据结构与算法 --- js描述集合
生活随笔
收集整理的這篇文章主要介紹了
数据结构与算法 --- js描述集合
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
js描述集合
function Set(){this.datasource=[];this.add=add;this.remove=remove;//this.size=size;//this.union=union;//this.intersect=intersect;//this.subset=subset;//this.difference=difference;this.show=show; }function add(data){if(this.datasource.indexOf(data)<0){this.datasource.push(data);return true;}else{return false;} } function remove(data){if(this.datasource.indexOf(data)<0){return false;}else{this.datasource.splice(this.datasource.indexOf(data),1);return true;} } function show(){console.log(this.datasource);return this.datasource; } var names=new Set(); names.add('aaaaa'); names.add('bbbbb'); names.add('ccccc'); names.add('ddddd');names.add('bbbbb') names.show();轉載于:https://www.cnblogs.com/frankltf/p/7581610.html
總結
以上是生活随笔為你收集整理的数据结构与算法 --- js描述集合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python Day28
- 下一篇: git的认识