首页 > 代码库 > js:数据结构笔记3--栈

js:数据结构笔记3--栈

栈是一种特殊的列表,数据结构为LIFO;

定义:

function Stack() {   this.dataStore = [];   this.top = 0;   this.push = push;   this.pop = pop;   this.peek = peek;    this.length = length;   this.clear =clear; }function push(elem) {   this.dataStore[this.top++] = elem;}function pop() {	var data = http://www.mamicode.com/this.dataStore[--this.top];>

  

  

js:数据结构笔记3--栈