fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.1 KiB

7 years ago
7 years ago
!(function () {
BI.Queue = function (capacity) {
this.capacity = capacity;
this.array = [];
};
BI.Queue.prototype = {
constructor: BI.Queue,
contains: function (v) {
return BI.contains(this.array, v);
7 years ago
},
indexOf: function (v) {
return BI.contains(this.array, v);
7 years ago
},
7 years ago
getElementByIndex: function (index) {
7 years ago
return this.array[index];
},
push: function (v) {
this.array.push(v);
if (this.capacity && this.array.length > this.capacity) {
this.array.shift();
}
},
pop: function () {
this.array.pop();
},
shift: function () {
this.array.shift();
},
unshift: function (v) {
this.array.unshift(v);
if (this.capacity && this.array.length > this.capacity) {
this.array.pop();
}
},
remove: function (v) {
BI.remove(this.array, v);
7 years ago
},
6 years ago
7 years ago
splice: function () {
this.array.splice.apply(this.array, arguments);
7 years ago
},
6 years ago
7 years ago
slice: function () {
this.array.slice.apply(this.array, arguments);
7 years ago
},
6 years ago
7 years ago
size: function () {
return this.array.length;
},
each: function (fn, scope) {
var scope = scope || window;
var fn = fn || null;
7 years ago
if (fn == null || typeof (fn) !== "function") {
7 years ago
return;
}
for (var i = 0; i < this.array.length; i++) {
var re = fn.call(scope, i, this.array[i], this.array);
if (re == false) {
break;
}
}
},
toArray: function () {
return this.array;
},
fromArray: function (array) {
var self = this;
BI.each(array, function (i, v) {
self.push(v);
7 years ago
});
7 years ago
},
clear: function () {
6 years ago
this.array.length = 0;
7 years ago
}
7 years ago
};
7 years ago
})();