jQuery.uniqueArray = function () {
this.items = new Array();
this.itemsCount = 0;
this.add = function (value) {
if (!this.contains(value)) {
this.items.push(value);
this.itemsCount++;
}
else
throw "The value '" + value + "' allready exists."
}
this.contains = function (value) {
return jQuery.inArray(value, this.items) > -1;
}
this.clear = function () {
this.items = new Array();
this.itemsCount = 0;
}
this.size = function () {
return this.itemsCount;
}
this.isEmpty = function () {
return this.size() == 0;
}
this.remove = function (value) {
if (this.contains(value)) {
var index = jQuery.inArray(value, this.items);
this.items.splice(index, 1);
this.itemsCount--;
}
else
throw "value '" + value + "' does not exists."
}
};
jQuey List (unique)
最新推荐文章于 2024-09-29 11:25:09 发布