摘要: function Queue() { this.dataStore = []; this.enqueue = enqueue; this.dequeue = dequeue; this.front = front; this.back = back; this.toString = toStr... 阅读全文
posted @ 2016-04-09 22:25 绯乐 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 队列是一种先进先出( First-In-First-Out, FIFO) 的数据结构。 【队列的表现可模拟为到银行办理业务的过程,先到者先办理,先离开,后到者需排队等待,后离开】 队列的两种主要操作是: 向队列中插入新元素和删除队列中的元素。 插入操作也叫做入队, 删除操作也叫做出队。 入队操作在队 阅读全文
posted @ 2016-04-09 22:15 绯乐 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 一、运用栈 二、间接使用数组的reverse()方法 阅读全文
posted @ 2016-04-09 21:59 绯乐 阅读(1970) 评论(0) 推荐(0) 编辑
摘要: var a = [ 1, 2 ], b = [ 1, 2 ], c = [ 1, 3 ]; alert(a == b);//false alert(a == c);//false,切记不能直接比较!! //法一: alert(a.toString() == b.toString());//true alert(a.toString() == c.... 阅读全文
posted @ 2016-04-09 21:38 绯乐 阅读(1123) 评论(0) 推荐(0) 编辑
摘要: function Stack() { this.dataStore = []; this.top = 0;//top的值等同于数组内的元素个数 this.push = push; this.pop = pop; } function push(element) { this.dataSt... 阅读全文
posted @ 2016-04-09 21:25 绯乐 阅读(733) 评论(0) 推荐(0) 编辑
摘要: 栈被称为一种后进先出( LIFO, last-in-first-out) 的数据结构。 tips:pop()&peek()的区别: pop() 方法可以访问栈顶的元素, 调用后, 栈顶元素从栈中被永久性地删除。 peek() 方法则只返回栈顶元素, 而不删除它。 阅读全文
posted @ 2016-04-09 20:15 绯乐 阅读(11397) 评论(0) 推荐(0) 编辑
摘要: function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.length = length;//返回列表中元素的个数 this.... 阅读全文
posted @ 2016-04-09 11:24 绯乐 阅读(288) 评论(0) 推荐(0) 编辑
摘要: function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.append = append;//在列表的末尾添加新元素,方法 ... 阅读全文
posted @ 2016-04-09 11:15 绯乐 阅读(165) 评论(0) 推荐(0) 编辑
摘要: function weekTemps() { this.dataStore = [];//属性 this.add = add;//方法 this.average = average;//方法 } function add(temp) { this.dataStore.push(temp); } ... 阅读全文
posted @ 2016-04-09 10:18 绯乐 阅读(486) 评论(0) 推荐(0) 编辑
摘要: function Point(x, y) { this.x = x; this.y = y; } function displayPts(arr) { for ( var i = 0; i "); } } var p1 = new Point(1, 2); var p2 = new P... 阅读全文
posted @ 2016-04-09 10:14 绯乐 阅读(152) 评论(0) 推荐(0) 编辑
摘要: var grades = [ [ 89, 77 ], [ 76, 82, 81 ], [ 91, 94, 89, 99 ] ]; var total = 0; var average = 0.0; for ( var row = 0; row "); total = 0; average = 0.0; } 阅读全文
posted @ 2016-04-09 10:04 绯乐 阅读(321) 评论(0) 推荐(1) 编辑