![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端数据结构
闲云野鹤_物竞天择
前端开发工程师
展开
-
[精华]javascript-es6集合的运算
javascript-es6-集合的运算 const setA=new Set() setA.add(1) setA.add(2) setA.add(3) const setB=new Set() setB.add(5) setB.add(6) setB.add(9) const union=(setA,setB)=>{ //并集运算 const unionAb=new Set() setA.forEach(value=>unionAb.add(value))原创 2020-12-08 15:52:35 · 391 阅读 · 0 评论 -
[精华] javascript-数据结构-集合
javascript-数据结构-集合 集合:无序的非重复的值的数据集 //创建集合类 class Set{ constructor(){ this.items={} } has(element){ //是否包含 return Object.prototype.hasOwnProperty.call(this.items,element); } add(element){ if(!this.has(element)){ //元素不存在的情况原创 2020-12-03 16:10:09 · 59 阅读 · 0 评论 -
[精华]javascript-数据结构-链表
[精华]javascript-模拟数据结构-链表 //链表的数据结构 class Node{ //节点类 constructor(element){ this.element=element; this.next=null; } } function equals(a,b){ return a===b; //对比两个元素是否相等 } class LinkList{ constructor(){ this.count=0; //用来存储链表的长度 this.equa原创 2020-12-02 15:50:30 · 84 阅读 · 0 评论 -
[精华]javascript-数据结构-队列-对象模拟
javascript-数据结构-队列-对象模拟 class Queue{ #count=0 #lastCount=0 #items={} peek(){ //返回队列第一个元素 return this.#items[this.#lastCount] } isEmpty(){ //队列是否为空 return this.#count==0 } size(){ //队列的长度 return this.#count-1 } enQu原创 2020-11-20 14:34:05 · 63 阅读 · 0 评论 -
[精华]javascript-数据结构-数组模拟队列结构
javascript-数据结构-数组模拟队列结构 //数组模拟队列 class Queue{ #count=0; #items=[]; enQueue(element){ //队列添加元素 this.#items.push(element) } deQueue(){ //移除队列的第一项并返回元素 if(this.isEmpty()){ return undefined; } return this.#ite原创 2020-11-20 10:03:17 · 135 阅读 · 0 评论 -
[精华]javascript-对象-模拟栈Stack操作
javascript-对象-模拟栈Stack操作 废话不多说直接上代码 class Stack{ constructor(){ this.count=0; this.items={}; } size(){ //栈的大小 return this.count; } isEmpty(){ return this.count==0; } push(val){ this.count++; //对象的下标从1开始原创 2020-11-19 11:20:49 · 115 阅读 · 0 评论 -
[精华]javascript-数据结构-数组模拟栈-教程
javascript数组模拟栈-数据结构 栈数据结构特点-后进先出 //javascript数组模拟栈结构 class Stack { constructor() { this.items = []; } push(element) { //栈顶添加元素 this.items.push(element); } pop() { //删除栈的元素 this.items.pop(); } peek() { //获取栈顶的元素原创 2020-11-18 11:16:59 · 144 阅读 · 0 评论