Skip to content

Commit

Permalink
made trimTrailingBits private
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoon committed Nov 3, 2019
1 parent 290d258 commit 0f09ee1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/BitSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export default class BitSet
{
index = index|0;

return ((this.words[index >>> WORD_LOG] >>> index) & ONE)|0
return (index >= this._length ? ZERO : (this.words[index >>> WORD_LOG] >>> index) & ONE)|0
}

/**
Expand Down Expand Up @@ -910,7 +910,7 @@ export default class BitSet
*
* @returns this.
*/
public trimTrailingBits(): BitSet
private trimTrailingBits(): BitSet
{
const wordsLength = this.words.length|0;
const diff = (wordsLength*WORD_SIZE - this._length)|0;
Expand Down
20 changes: 0 additions & 20 deletions test/unit/BitSet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,26 +1046,6 @@ describe('trim', () =>
});
});

describe('trimTrailingBits', () =>
{
it('should return set, bitstring or full bitstring depending on mode', () =>
{
const bs = BitSet.create(55).add(9).add(14).add(50);

bs.words[1] |= (1 << 60); // set a 1 at index 60 the unofficial way :-)

const str = bs.toString(-1);

expect(str).to.eql('0001000000000100000000000000000000000000000000000100001000000000');
expect(str.length).to.eql(64);
expect(bs.length).to.eql(55);

bs.trimTrailingBits();

expect(bs.toString(-1)).to.eql('0000000000000100000000000000000000000000000000000100001000000000');
});
});

describe('union', () =>
{
it('should calculate the union of 2 sets', () =>
Expand Down

0 comments on commit 0f09ee1

Please sign in to comment.