Add ol.structs.RBush#isEmpty
This commit is contained in:
@@ -574,6 +574,14 @@ ol.structs.RBush.prototype.insert_ = function(extent, value, level) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.structs.RBush.prototype.isEmpty = function() {
|
||||
return this.root_.children.length === 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {T} value Value.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,14 @@ describe('ol.structs.RBush', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#isEmpty', function() {
|
||||
|
||||
it('returns true', function() {
|
||||
expect(rBush.isEmpty()).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with a few objects', function() {
|
||||
@@ -76,6 +84,14 @@ describe('ol.structs.RBush', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isEmpty', function() {
|
||||
|
||||
it('returns false', function() {
|
||||
expect(rBush.isEmpty()).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#remove', function() {
|
||||
|
||||
it('can remove each object', function() {
|
||||
@@ -155,6 +171,14 @@ describe('ol.structs.RBush', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#isEmpty', function() {
|
||||
|
||||
it('returns false', function() {
|
||||
expect(rBush.isEmpty()).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#remove', function() {
|
||||
|
||||
it('can remove each object in turn', function() {
|
||||
@@ -165,6 +189,7 @@ describe('ol.structs.RBush', function() {
|
||||
expect(rBush.getAllInExtent(extents[i])).to.be.empty();
|
||||
}
|
||||
expect(rBush.getAll()).to.be.empty();
|
||||
expect(rBush.isEmpty()).to.be(true);
|
||||
});
|
||||
|
||||
it('can remove objects in random order', function() {
|
||||
@@ -183,6 +208,7 @@ describe('ol.structs.RBush', function() {
|
||||
expect(rBush.getAllInExtent(extents[index])).to.be.empty();
|
||||
}
|
||||
expect(rBush.getAll()).to.be.empty();
|
||||
expect(rBush.isEmpty()).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -260,6 +286,14 @@ describe('ol.structs.RBush', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#isEmpty', function() {
|
||||
|
||||
it('returns false', function() {
|
||||
expect(rBush.isEmpty()).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user