Skip to content

Commit

Permalink
(#21) LinkedHashMap should return if the map is empty or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Tang committed Feb 12, 2014
1 parent b05648e commit 3de7704
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/LinkedHashMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
getSize: function getSize() {
return this.private.count;
},
isEmpty: function isEmpty() {
return this.private.count === 0;
},
/**
* Removes a node with a given key
*
Expand Down
7 changes: 7 additions & 0 deletions test/spec/LinkedHashMapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
expect(list.removeFirst()).toEqual(false);
expect(list.removeLast()).toEqual(false);
});

it('should return true when the map is empty, but false when it is not', function emptyMap() {
var list = new LinkedHashMap();
expect(list.isEmpty()).toEqual(true);
list.add(0, 'hello');
expect(list.isEmpty()).toEqual(false);
});
});

describe('modifying an LinkedHashMap', function modifyLinkedHashMapSpecs() {
Expand Down

0 comments on commit 3de7704

Please sign in to comment.