bitarray

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	// contains filtered or unexported fields
}

Array is an optimized array of boolean values. The zero value is ready to use. Do not copy a non-zero Array.

func And

func And(array1, array2 *Array) *Array

And performs bitwise AND operation on two arrays and returns the result.

func New

func New() *Array

New creates an empty Array.

func NewFromSlice

func NewFromSlice(slice []bool) *Array

NewFromSlice creates an Array from the specified slice.

func NewWithCapacity

func NewWithCapacity(initialCapacity int) *Array

NewWithCapacity creates an empty Array with the specified initial capacity.

func NewWithSize

func NewWithSize(initialSize int) *Array

NewWithSize creates an empty Array with the specified initial size.

func Not

func Not(array *Array) *Array

Not performs bitwise NOT operation on an array and returns the result.

func Or

func Or(array1, array2 *Array) *Array

Or performs bitwise OR operation on two arrays and returns the result.

func ShiftLeft

func ShiftLeft(array *Array, operationType ShiftType) *Array

ShiftLeft performs bitwise left shift operation on an array and returns the result.

func ShiftRight

func ShiftRight(array *Array, operationType ShiftType) *Array

ShiftRight performs bitwise right shift operation on an array and returns the result.

func Xor

func Xor(array1, array2 *Array) *Array

Xor performs bitwise XOR operation on two arrays and returns the result.

func (*Array) All

func (array *Array) All() bool

All returns true if all bits are set to 1.

func (*Array) And

func (array *Array) And(other *Array)

And performs an in-place bitwise AND operation with the other array.

func (*Array) Any

func (array *Array) Any() bool

Any returns true if any bit is set to 1.

func (*Array) Append

func (array *Array) Append(value bool)

Append appends the specified bit value to the end of the Array.

func (*Array) Capacity

func (array *Array) Capacity() int

Capacity returns the number of bits that the Array can hold without reallocating.

func (*Array) Clear

func (array *Array) Clear()

Clear removes all bits from the Array.

func (*Array) Clone

func (array *Array) Clone() *Array

Clone returns a shallow copy of the Array.

func (*Array) Count

func (array *Array) Count() int

Count returns the number of bits set to 1.

func (*Array) Flip

func (array *Array) Flip(index int)

Flip flips the bit at the specified index.

func (*Array) FlipAll

func (array *Array) FlipAll()

FlipAll flips all bits in the Array.

func (*Array) Get

func (array *Array) Get(index int) bool

Get returns the bit at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.

func (*Array) Insert

func (array *Array) Insert(index int, value bool)

Insert inserts the specified bit value at the specified index.

func (*Array) Join

func (array *Array) Join(other *Array)

Join appends all bits from the specified Array to the end of the Array.

func (*Array) None

func (array *Array) None() bool

None returns true if no bit is set to 1.

func (*Array) Or

func (array *Array) Or(other *Array)

Or performs an in-place bitwise OR operation with the other array.

func (*Array) Remove

func (array *Array) Remove(index int)

Remove removes the bit at the specified index.

func (*Array) Reverse

func (array *Array) Reverse()

Reverse reverses the order of the bits in the Array.

func (*Array) Set

func (array *Array) Set(index int, value bool)

Set sets the bit at the specified index to the specified value. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.

func (*Array) SetAll

func (array *Array) SetAll(value bool)

SetAll sets all bits in the Array to the specified value.

func (*Array) ShiftLeft

func (array *Array) ShiftLeft(operationType ShiftType)

ShiftLeft performs an in-place left shift operation on the array.

func (*Array) ShiftRight

func (array *Array) ShiftRight(operationType ShiftType)

ShiftRight performs an in-place right shift operation on the array.

func (*Array) Size

func (array *Array) Size() int

Size returns the number of bits in the Array.

func (*Array) String

func (array *Array) String() string

String returns a string representation of the Array.

func (*Array) Xor

func (array *Array) Xor(other *Array)

Xor performs an in-place bitwise XOR operation with the other array.

type ShiftType

type ShiftType uint8

ShiftType is an enum for the type of shift operation to perform.

const (
	FillZero   ShiftType = iota // FillZero is a shift type that fills the empty bits with zeros.
	FillOne                     // FillOne is a shift type that fills the empty bits with ones.
	Arithmetic                  /*
		Arithmetic is a shift type that fills the empty bits with the same value
		as the sign bit during a right shift, and with zeros during a left shift.
	*/
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL