a fast bitset with some neat methods
npm install fast-bitset

A fast bitset with some nice methods.
##Features
- Outperforms all other bitset packages in terms of speed and space
- All bit operations execute in O(1) time (does not iterate through bits)
- Useful methods for graph algorithms
- Any array that stores booleans can safely be replaced by a bitset for improved speed
- Uses 64x less space than a nontyped array
##Installation
npm install fast-bitset --save
##License
MIT
##API
* BitSet
* new BitSet(nBitsOrKey)
* .get(idx) ⇒ boolean
* .set(idx) ⇒ boolean
* .setRange(from, to) ⇒ boolean
* .unset(idx) ⇒ boolean
* .unsetRange(from, to) ⇒ boolean
* .toggle(idx) ⇒ boolean
* .toggleRange(from, to) ⇒ boolean
* .clear() ⇒ boolean
* .clone() ⇒ BitSet
* .dehydrate() ⇒ string
* .and(bsOrIdx) ⇒ BitSet
* .or(bsOrIdx) ⇒ BitSet
* .xor(bsOrIdx) ⇒ BitSet
* .forEach(func)
* .getCardinality() ⇒ number
* .getIndices() ⇒ Array
* .isSubsetOf(bitset) ⇒ Boolean
* .isEmpty() ⇒ boolean
* .isEqual(bs) ⇒ boolean
* .toString() ⇒ string
* .ffs(_startWord) ⇒ number
* .ffz(_startWord) ⇒ number
* .fls(_startWord) ⇒ number
* .flz(_startWord) ⇒ number
* .nextSetBit(idx) ⇒ number
* .nextUnsetBit(idx) ⇒ number
* .previousSetBit(idx) ⇒ number
* .previousUnsetBit(idx) ⇒ number
| Param | Type | Description |
| --- | --- | --- |
| nBitsOrKey | number | string | Number of bits in the set or dehydrated bitset. For speed and space concerns, the initial number of bits cannot be increased. |
Kind: instance method of BitSet
Returns: boolean - true if bit is set, else false
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the position of a single bit to check |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the position of a single bit to set |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| from | number | the starting index of the range to set |
| to | number | the ending index of the range to set |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the position of a single bit to unset |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| from | number | the starting index of the range to unset |
| to | number | the ending index of the range to unset |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the position of a single bit to toggle |
Kind: instance method of BitSet
Returns: boolean - true if set was successful, else false
| Param | Type | Description |
| --- | --- | --- |
| from | number | the starting index of the range to toggle |
| to | number | the ending index of the range to toggle |
Kind: instance method of BitSet
Returns: boolean - true
Kind: instance method of BitSet
Returns: BitSet - an copy (by value) of the calling bitset
Kind: instance method of BitSet
Returns: string - representation of the bitset
Kind: instance method of BitSet
Returns: BitSet - a new bitset that is the bitwise AND of the two
| Param | Type | Description |
| --- | --- | --- |
| bsOrIdx | BitSet | Number | a bitset or single index to check (useful for LP, DP problems) |
Kind: instance method of BitSet
Returns: BitSet - a new bitset that is the bitwise OR of the two
| Param | Type | Description |
| --- | --- | --- |
| bsOrIdx | BitSet | Number | a bitset or single index to check (useful for LP, DP problems) |
Kind: instance method of BitSet
Returns: BitSet - a new bitset that is the bitwise XOR of the two
| Param | Type | Description |
| --- | --- | --- |
| bsOrIdx | BitSet | Number | a bitset or single index to check (useful for LP, DP problems) |
get()Kind: instance method of BitSet
| Param | Type | Description |
| --- | --- | --- |
| func | function | the function to pass the next set bit to |
Kind: instance method of BitSet
Returns: number - cardinality
forEach internallyKind: instance method of BitSet
Returns: Array - Indices of all set bits
Kind: instance method of BitSet
Returns: Boolean - true if provided bitset is a subset of this bitset, false otherwise
| Param | Type | Description |
| --- | --- | --- |
| bs | BitSet | a bitset to check |
Kind: instance method of BitSet
Returns: boolean - true if the entire bitset is empty, else false
Kind: instance method of BitSet
Returns: boolean - true if the entire bitset is empty, else false
| Param | Type |
| --- | --- |
| bs | BitSet |
Kind: instance method of BitSet
Returns: string - a base 2 representation of the entire bitset
Kind: instance method of BitSet
Returns: number - the index of the first set bit in the bitset, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| _startWord | number | the word to start with (only used internally by nextSetBit) |
Kind: instance method of BitSet
Returns: number - the index of the first unset bit in the bitset, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| _startWord | number | the word to start with (only used internally by nextUnsetBit) |
Kind: instance method of BitSet
Returns: number - the index of the last set bit in the bitset, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| _startWord | number | the word to start with (only used internally by previousSetBit) |
Kind: instance method of BitSet
Returns: number - the index of the last unset bit in the bitset, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| _startWord | number | the word to start with (only used internally by previousUnsetBit) |
Kind: instance method of BitSet
Returns: number - the index of the next set bit >= idx, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the starting index for the next set bit |
Kind: instance method of BitSet
Returns: number - the index of the next unset bit >= idx, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the starting index for the next unset bit |
Kind: instance method of BitSet
Returns: number - the index of the next unset bit <= idx, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the starting index for the next unset bit (going in reverse) |
Kind: instance method of BitSet
Returns: number - the index of the next unset bit <= idx, or -1 if not found
| Param | Type | Description |
| --- | --- | --- |
| idx | number | the starting index for the next unset bit (going in reverse) |