BitArrays64

Usage

use BitArrays.BitArrays64;

or

import BitArrays.BitArrays64;
type bit64Index = int
class BitArray64

BitArray64 is an array of boolean values packed together as 64 bit words. All boolean values are mapped one-to-one to a bit in a 64 bit unsigned integer.

proc init(size: bit64Index, locales = Locales)

Create a bit array of a given size.

Arguments
  • size – The size of the bit array

  • locales – What nodes to distibute the values over

proc init(ref values: [] uint(64), size: bit64Index)

Create a bit array from a given set of values. * The input values must be a rectangular 1-dimensional array. * The input values must not be a sparse array. * The input values must not be an associative array.

Arguments
  • values – The valuess in the bit array stored as 64 bit integers. If the size does is not a multiple of 32 then one extra value must be added to contain the reminder bits.

  • size – The number of individual bits in the bit array.

proc all(): bool

Test if all the values are true.

Returns

true if any of the values are true

Return type

bool

proc any(): bool

Test if any of the values are true

Returns

true if any of the values are true

Return type

bool

proc at(idx: bit64Index): bool throws

Look up value at index idx.

Arguments

idx – The index in the bitarray to look up.

Throws

BitRangeError – If idx is outside the range [1..size).

Returns

value at idx

Return type

bool

proc equals(rhs: BitArray64): bool

Compares two bit arrays by values.

Returns

true if the two bit arrays has identical values.

Return type

bool

proc fill()

Set all the values to true.

proc popcount()

Count the number of values set to true.

Returns

The count

Return type

int

proc reverse()

Reverse the ordering of the values. The last value becomes the first value. The second last value becomes the second first value. And so on.

proc set(idx: bit64Index, value: bool) throws

Set the value at a given index.

Arguments
  • idx – The index of the value.

  • value – The value to set.

Throws

BitRangeError – if the idx value is outside the range [0, size).

proc size()

Get the number of values.

Returns

bit vector size.

Return type

int(64)

iter these()

Iterate over all the values.

Yields

All the values

Yields type

bool

iter trueIndices()

Iterate over the index of all the values that are true.

Yields

The index of a true value

Yields type

int

proc unfill()

Set all the values to false.

proc type ==(lhs: BitArray64, rhs: BitArray64)

Compares parwise the values of the two bit arrays for equality.

Arguments
  • lhs – left hand bit array

  • rhs – right hand bit array

Returns

if the bits in the arrays are equal

Return type

list

proc type !=(lhs: BitArray64, rhs: BitArray64)

Compares parwise the values of the two bit arrays for inequality

Arguments
  • lhs – left hand bit array

  • rhs – right hand bit array

Returns

if the bits in the arrays are equal

Return type

BitArray64

proc type =(ref lhs: BitArray64, rhs: BitArray64)

Copies the values from an rhs bit array.

Arguments
  • lhs – the left hand bit array to assign

  • rhs – The right hand array to copy

proc type <<(lhs: BitArray64, shift: integral): BitArray64 throws

Shift the values shift values to the right. Missing right values are padded with false values.

Arguments

shift – the number of values to shift.

Returns

A copy of the values shifted to the right.

Return type

BitArray64

Throws

ShiftRangeError – If shift is less than zero or bigger than the size of the bit array.

proc type <<=(ref lhs: BitArray64, shift: integral) throws

Shift all the values to the right. Left values are padded with false values.

Arguments

shift – the number of values to shift.

Throws

ShiftRangeError – If shift is less than zero or bigger than the size of the bit array.

proc type >>(lhs: BitArray64, shift: integral): BitArray64 throws

Shift the values shift positions to the left. Missing left values are padded with false values.

Arguments

shift – the number of values to shift.

Returns

a copy of the values shifted shift positions to the left.

Return type

BitArray64

Throws

ShiftRangeError – If shift is less than zero or bigger than the size of the bit array.

proc type >>=(ref lhs: BitArray64, shift: integral) throws

Shift all the values to the right. Left values are padded with false values.

Arguments

shift – the number of values to shift.

Throws

ShiftRangeError – If shift is less than zero or bigger than the size of the bit array.

proc type ^(lhs: BitArray64, rhs: BitArray64)

Perform xor the values with the corresponding values in the input bit array. X[i] ^ Y[i] is performed for all indices i where X and Y are bit arrays. If one of the two bit arrays has different size then indices fitting the shortes bit array are compared.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform xor with

Returns

The results

Return type

BitArray64

proc type ^=(ref lhs: BitArray64, rhs: BitArray64)

Perform xor the values with the corresponding values in the input bit array. X[i] ^ Y[i] is performed for all indices i where X and Y are bit arrays. If one of the two bit arrays has different size then indices fitting the shortes bit array are compared.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform xor with

proc type &(lhs: BitArray64, rhs: BitArray64): BitArray64

Perform the and operation on the values in this bit array with the values in another bit array. If one of the two bit arrays has different size then indices fitting the shortes bit array are compared.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform and with

Returns

the results

Return type

BitArray64

proc type &=(ref lhs: BitArray64, rhs: BitArray64): BitArray64

Perform the and operation on the values in this bit array with the values in another bit array. lhs is updated with the result of the operation.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform and with

proc type +(lhs: BitArray64, rhs: BitArray64): BitArray64

Perform the or operation on the values in this bit array with the values in another bit array.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform or with

Returns

A copy of the values from lhs or rhs

Return type

BitArray64

proc type +=(ref lhs: BitArray64, rhs: BitArray64)
Perform the or operation on the values in this bit array with the values in another bit array.

lhs is updated with the result of the operation.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform or with

proc type -(lhs: BitArray64, rhs: BitArray64)

Perform the minus operation on the values in this bit array with the values in another bit array. The result is all the values in lhs which are not present in rhs.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform minus with

Returns

The result of lhs - rhs

Return type

BitArray64

proc type -=(ref lhs: BitArray64, rhs: BitArray64)

Perform the minus operation on the values in this bit array with the values in another bit array. The result is all the values in lhs which are not present in rhs.

Arguments
  • lhs – this bit array

  • rhs – bit array to perform minus with