Class: BitSet
dg.BitSet
Efficient bit storage and manipulation. See samples: https://public.datagrok.ai/js/samples/data-frame/aggregation
Constructors
constructor
• new BitSet(dart
)
Creates a {BitSet} from the specified Dart object.
Parameters
Name | Type |
---|---|
dart | any |
Defined in
Properties
dart
• dart: any
Defined in
Accessors
anyFalse
• get
anyFalse(): boolean
Whether any bits are set to false.
Returns
boolean
Defined in
anyTrue
• get
anyTrue(): boolean
Whether any bits are set to true.
Returns
boolean
Defined in
falseCount
• get
falseCount(): number
Number of unset bits
Returns
number
Defined in
length
• get
length(): number
Number of bits in a bitset
Returns
number
Defined in
onChanged
• get
onChanged(): Observable
<any
>
Returns
Observable
<any
>
- fires when the bitset gets changed.
Defined in
trueCount
• get
trueCount(): number
Number of set bits
Returns
number
Defined in
Methods
and
▸ and(other
, notify?
): BitSet
Modifies this bitset by performing the bitwise AND operation against the specified bitset. Returns this.
Parameters
Name | Type | Default value |
---|---|---|
other | BitSet | undefined |
notify | boolean | true |
Returns
Defined in
andNot
▸ andNot(other
, notify?
): BitSet
Modifies this bitset by performing the bitwise AND_NOT operation against the specified bitset. Returns this.
Parameters
Name | Type | Default value |
---|---|---|
other | BitSet | undefined |
notify | boolean | true |
Returns
Defined in
clone
▸ clone(): BitSet
Clones a bitset
Returns
Defined in
copyFrom
▸ copyFrom(b
, notify?
): BitSet
Copies the content from the other {BitSet}.
Parameters
Name | Type | Default value |
---|---|---|
b | BitSet | undefined |
notify | boolean | true |
Returns
Defined in
findNext
▸ findNext(i
, x
): number
Finds the first index of value x, going forward from i-th position.
Parameters
Name | Type | Description |
---|---|---|
i | number | index |
x | boolean |
Returns
number
Defined in
findPrev
▸ findPrev(i
, x
): number
Finds the first index of value x, going forward from i-th position, or -1 if not found.
Parameters
Name | Type | Description |
---|---|---|
i | number | Index to start searching from. |
x | boolean | Value to search for. |
Returns
number
Defined in
fireChanged
▸ fireChanged(): void
Returns
void
Defined in
get
▸ get(i
): boolean
Gets i-th bit
Parameters
Name | Type |
---|---|
i | number |
Returns
boolean
Defined in
getBuffer
▸ getBuffer(): Int32Array
Returns the underlying storage. Be careful with the direct manipulations, as some statistics (set count, etc) are cached.
Returns
Int32Array
Defined in
getSelectedIndexes
▸ getSelectedIndexes(): Int32Array
Indexes of all set bits. The result is cached.
Returns
Int32Array
Defined in
handleClick
▸ handleClick(rowIndexPredicate
, mouseEvent
, modifiedSelectOnly?
): void
Parameters
Name | Type | Default value |
---|---|---|
rowIndexPredicate | IndexPredicate | undefined |
mouseEvent | MouseEvent | undefined |
modifiedSelectOnly | boolean | false |
Returns
void
Defined in
init
▸ init(f
, notify?
): BitSet
Sets all bits by setting i-th bit to the results of f(i)
Parameters
Name | Type | Default value | Description |
---|---|---|---|
f | IndexPredicate | undefined | function that accepts bit index and returns bit value |
notify | boolean | true | whether BitSet's changed event should be fired |
Returns
- this
Defined in
invert
▸ invert(notify?
): BitSet
Inverts a bitset.
Parameters
Name | Type | Default value |
---|---|---|
notify | boolean | true |
Returns
Defined in
or
▸ or(other
, notify?
): BitSet
Modifies this bitset by performing the bitwise OR operation against the specified bitset. Returns this.
Parameters
Name | Type | Default value |
---|---|---|
other | BitSet | undefined |
notify | boolean | true |
Returns
Defined in
set
▸ set(i
, x
, notify?
): void
Sets i-th bit to x
Parameters
Name | Type | Default value | Description |
---|---|---|---|
i | number | undefined | |
x | boolean | undefined | |
notify | boolean | true | whether BitSet's changed event should be fired |
Returns
void
Defined in
setAll
▸ setAll(x
, notify?
): BitSet
Sets all bits to x
Parameters
Name | Type | Default value | Description |
---|---|---|---|
x | boolean | undefined | |
notify | boolean | true | whether BitSet's changed event should be fired |
Returns
Defined in
similarityTo
▸ similarityTo(b
, metric?
): number
Finds the value of similarity between two BitSets.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
b | BitSet | undefined | second BitSet. |
metric | "tanimoto" | "dice" | "cosine" | "sokal" | "russel" | "rogot-goldberg" | "kulczynski" | "mc-connaughey" | "asymmetric" | "braun-blanquet" | SIMILARITY_METRIC.TANIMOTO | similarity metric to use. |
Returns
number
Defined in
toBinaryString
▸ toBinaryString(): string
Returns
string
Defined in
toString
▸ toString(): string
Returns
string
Defined in
xor
▸ xor(other
, notify?
): BitSet
Modifies this bitset by performing the bitwise XOR operation against the specified bitset. Returns this.
Parameters
Name | Type | Default value |
---|---|---|
other | BitSet | undefined |
notify | boolean | true |
Returns
Defined in
create
▸ Static
create(length
, f?
): BitSet
Creates a {BitSet} of the specified length with all bits set to false.
Parameters
Name | Type | Description |
---|---|---|
length | number | Number of bits. |
f? | null | IndexPredicate | when specified, Sets all bits by setting i-th bit to the results of f(i) |
Returns
Defined in
fromBytes
▸ Static
fromBytes(buffer
, bitLength
): BitSet
Creates a {BitSet} from the ArrayBuffer representing the bitset.
Parameters
Name | Type | Description |
---|---|---|
buffer | ArrayBuffer | An array containing 1 and 0. |
bitLength | number | count of bits. |
Returns
Defined in
fromString
▸ Static
fromString(zerosOnes
): BitSet
Creates a {BitSet} from the string representing the bitset.
Parameters
Name | Type | Description |
---|---|---|
zerosOnes | string | A string containing '1' and '0'. |