日期:2014-05-16 浏览次数:20346 次
//js's queue by yj function js_queue(){ this.head = 0; this.arr = new Array(); } js_queue.prototype.put = function(obj){ this.arr[this.arr.length] = obj; } js_queue.prototype.get = function(){ if(this.head == this.arr.length) return null; var return_string = this.arr[this.head]; this.head += 1; return return_string; } var q = new js_queue(); q.put('s1'); q.put('s2'); q.put('s3'); alert(q.get()); alert(q.get()); alert(q.get()); alert(q.get());