Skip to main content

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

NameType
dartany

Defined in

src/dataframe.ts:1538

Properties

dart

dart: any

Defined in

src/dataframe.ts:1535

Accessors

anyFalse

get anyFalse(): boolean

Whether any bits are set to false.

Returns

boolean

Defined in

src/dataframe.ts:1600


anyTrue

get anyTrue(): boolean

Whether any bits are set to true.

Returns

boolean

Defined in

src/dataframe.ts:1597


falseCount

get falseCount(): number

Number of unset bits

Returns

number

Defined in

src/dataframe.ts:1592


length

get length(): number

Number of bits in a bitset

Returns

number

Defined in

src/dataframe.ts:1582


onChanged

get onChanged(): Observable<any>

Returns

Observable<any>

  • fires when the bitset gets changed.

Defined in

src/dataframe.ts:1733


trueCount

get trueCount(): number

Number of set bits

Returns

number

Defined in

src/dataframe.ts:1587

Methods

and

and(other, notify?): BitSet

Modifies this bitset by performing the bitwise AND operation against the specified bitset. Returns this.

Parameters

NameTypeDefault value
otherBitSetundefined
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1617


andNot

andNot(other, notify?): BitSet

Modifies this bitset by performing the bitwise AND_NOT operation against the specified bitset. Returns this.

Parameters

NameTypeDefault value
otherBitSetundefined
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1638


clone

clone(): BitSet

Clones a bitset

Returns

BitSet

Defined in

src/dataframe.ts:1604


copyFrom

copyFrom(b, notify?): BitSet

Copies the content from the other {BitSet}.

Parameters

NameTypeDefault value
bBitSetundefined
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1723


findNext

findNext(i, x): number

Finds the first index of value x, going forward from i-th position.

Parameters

NameTypeDescription
inumberindex
xboolean

Returns

number

Defined in

src/dataframe.ts:1656


findPrev

findPrev(i, x): number

Finds the first index of value x, going forward from i-th position, or -1 if not found.

Parameters

NameTypeDescription
inumberIndex to start searching from.
xbooleanValue to search for.

Returns

number

Defined in

src/dataframe.ts:1664


fireChanged

fireChanged(): void

Returns

void

Defined in

src/dataframe.ts:1728


get

get(i): boolean

Gets i-th bit

Parameters

NameType
inumber

Returns

boolean

Defined in

src/dataframe.ts:1671


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

src/dataframe.ts:1572


getSelectedIndexes

getSelectedIndexes(): Int32Array

Indexes of all set bits. The result is cached.

Returns

Int32Array

Defined in

src/dataframe.ts:1718


handleClick

handleClick(rowIndexPredicate, mouseEvent, modifiedSelectOnly?): void

Parameters

NameTypeDefault value
rowIndexPredicateIndexPredicateundefined
mouseEventMouseEventundefined
modifiedSelectOnlybooleanfalse

Returns

void

Defined in

src/dataframe.ts:1750


init

init(f, notify?): BitSet

Sets all bits by setting i-th bit to the results of f(i)

Parameters

NameTypeDefault valueDescription
fIndexPredicateundefinedfunction that accepts bit index and returns bit value
notifybooleantruewhether BitSet's changed event should be fired

Returns

BitSet

  • this

Defined in

src/dataframe.ts:1700


invert

invert(notify?): BitSet

Inverts a bitset.

Parameters

NameTypeDefault value
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1610


or

or(other, notify?): BitSet

Modifies this bitset by performing the bitwise OR operation against the specified bitset. Returns this.

Parameters

NameTypeDefault value
otherBitSetundefined
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1624


set

set(i, x, notify?): void

Sets i-th bit to x

Parameters

NameTypeDefault valueDescription
inumberundefined
xbooleanundefined
notifybooleantruewhether BitSet's changed event should be fired

Returns

void

Defined in

src/dataframe.ts:1680


setAll

setAll(x, notify?): BitSet

Sets all bits to x

Parameters

NameTypeDefault valueDescription
xbooleanundefined
notifybooleantruewhether BitSet's changed event should be fired

Returns

BitSet

Defined in

src/dataframe.ts:1647


similarityTo

similarityTo(b, metric?): number

Finds the value of similarity between two BitSets.

Parameters

NameTypeDefault valueDescription
bBitSetundefinedsecond BitSet.
metric"tanimoto" | "dice" | "cosine" | "sokal" | "russel" | "rogot-goldberg" | "kulczynski" | "mc-connaughey" | "asymmetric" | "braun-blanquet"SIMILARITY_METRIC.TANIMOTOsimilarity metric to use.

Returns

number

Defined in

src/dataframe.ts:1741


toBinaryString

toBinaryString(): string

Returns

string

Defined in

src/dataframe.ts:1576


toString

toString(): string

Returns

string

Defined in

src/dataframe.ts:1746


xor

xor(other, notify?): BitSet

Modifies this bitset by performing the bitwise XOR operation against the specified bitset. Returns this.

Parameters

NameTypeDefault value
otherBitSetundefined
notifybooleantrue

Returns

BitSet

Defined in

src/dataframe.ts:1631


create

Static create(length, f?): BitSet

Creates a {BitSet} of the specified length with all bits set to false.

Parameters

NameTypeDescription
lengthnumberNumber of bits.
f?null | IndexPredicatewhen specified, Sets all bits by setting i-th bit to the results of f(i)

Returns

BitSet

Defined in

src/dataframe.ts:1563


fromBytes

Static fromBytes(buffer, bitLength): BitSet

Creates a {BitSet} from the ArrayBuffer representing the bitset.

Parameters

NameTypeDescription
bufferArrayBufferAn array containing 1 and 0.
bitLengthnumbercount of bits.

Returns

BitSet

Defined in

src/dataframe.ts:1553


fromString

Static fromString(zerosOnes): BitSet

Creates a {BitSet} from the string representing the bitset.

Parameters

NameTypeDescription
zerosOnesstringA string containing '1' and '0'.

Returns

BitSet

Defined in

src/dataframe.ts:1545