Copy Code code as follows:
/*
* List size variable array
* version:1.0
*/
function List () {
This.list = new Array ();
};
/**
* Adds the specified element to the tail of this list.
* @param element specified by object
*/
List.prototype.add = function (object) {
This.list[this.list.length] = object;
};
/**
* Add list to the tail of this list.
* @param listObject a list
*/
List.prototype.addAll = function (listObject) {
This.list = This.list.concat (listobject.list);
};
/**
* Returns the element at the specified position in this list.
* @param index specified location
* @return element of this position
*/
List.prototype.get = function (index) {
return This.list[index];
};
/**
* Removes the element at the specified location in this list.
* @param index specified location
* @return element of this position
*/
List.prototype.removeIndex = function (index) {
var object = This.list[index];
This.list.splice (index, 1);
return object;
};
/**
* Removes the specified element from this list.
* @param object to specify elements
* @return element of this position
*/
List.prototype.remove = function (object) {
var i = 0;
for (; i < this.list.length; i++) {
if (this.list[i] = = object) {
Break
}
}
if (i >= this.list.length) {
return null;
} else {
return This.removeindex (i);
}
};
/**
* Remove all elements from this list.
*/
List.prototype.clear = function () {
This.list.splice (0, this.list.length);
};
/**
* Returns the number of elements in this list.
* Number of @return elements
*/
List.prototype.size = function () {
return this.list.length;
};
/**
* Returns a list of the specified start (including) and end (not included) in the list.
* @param start position
* @param End Position
* @return a new list
*/
List.prototype.subList = function (start, end) {
var list = new List ();
List.list = This.list.slice (start, end);
return list;
};
/**
* Returns True if the list contains no elements.
* @return True or False
*/
List.prototype.isEmpty = function () {
return this.list.length = = 0;
};