Add ol.structs.RBush#isEmpty

This commit is contained in:
Tom Payne
2013-12-04 14:48:21 +01:00
parent 10db521898
commit 2be40a1ae6
2 changed files with 42 additions and 0 deletions

View File

@@ -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.
*/

View File

@@ -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);
});
});
});
});