Add ol.Collection.remove
This commit is contained in:
@@ -6,5 +6,6 @@
|
||||
@exportProperty ol.Collection.prototype.insertAt
|
||||
@exportProperty ol.Collection.prototype.pop
|
||||
@exportProperty ol.Collection.prototype.push
|
||||
@exportProperty ol.Collection.prototype.remove
|
||||
@exportProperty ol.Collection.prototype.removeAt
|
||||
@exportProperty ol.Collection.prototype.setAt
|
||||
|
||||
@@ -159,6 +159,22 @@ ol.Collection.prototype.push = function(elem) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes the first occurence of elem from the collection.
|
||||
* @param {*} elem Element.
|
||||
* @return {*} The removed element or undefined if elem was not found.
|
||||
*/
|
||||
ol.Collection.prototype.remove = function(elem) {
|
||||
var i;
|
||||
for (i = 0; i < this.array_.length; ++i) {
|
||||
if (this.array_[i] === elem) {
|
||||
return this.removeAt(i);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} index Index.
|
||||
* @return {*} Value.
|
||||
|
||||
Reference in New Issue
Block a user