Questions tagged [bitvector]

A data structure for an array of single bit values, usually with emphasis on memory-efficient storage and performance.

A bit Vector stores an array of single bit values (0,1) usually in a memory-efficient (i.e. packed) way. Typical operations on a bit vector are

  • access to single bits
  • boolean operations between two bit vectors (AND, OR, XOR, NOT)
  • vector-like operations (append/prepend, insertion of bits)
  • shift operations

Implementation are often optimized to use operations provided by the CPU to perform these operations in an performant way.

References

137 questions
0
votes
2 answers

Determine whether a UTF-32 encoded string has unique characters

I have a question about using the bit-vector approach that is common to finding whether a string has unique characters. I have seen those solutions out there (one of them) work well for ASCII and UTF-16 character set. However, how will the same…
neer
  • 98
  • 2
  • 5
0
votes
1 answer

How to encode the complex data for the neural network in the best way?

The data consist from the several records. A record is as the following: [bit vector, numeric vector, a few numeric values]. Bit vector has the different length for each record and the same is true for the numeric vector. The number of numeric…
Anton Danilov
  • 1,151
  • 9
  • 23
0
votes
1 answer

A memcpy()-like function for bit vectors?

I have a vector of bits, and I want to copy a slice of it to another vector (say, for simplicity, to the beginning of another vector). Note that all the bits may need to be shifted (or rather, rotated) in some direction, not just the first element,…
einpoklum
  • 86,754
  • 39
  • 223
  • 453
0
votes
2 answers

How do I convert a SQL Server 'Int' field to 'BitVector32' within my C# program?

Total beginner jumping in the deep end. This is my first post here. I'm a mainframe programmer trying to join the 1990's and learn some object oriented programming(which is currently greek to me). Please forgive my elementary explanation below. I'm…
0
votes
2 answers

Merge bits, then determine how many 0s the result has

I am trying to write a function which takes in three bit vectors representing the digits in use in the row, col and block of a Sudoku puzzle from positions 1-9. A cell can only use digits that are unused, and the function is supposed to return…
user1697083
0
votes
1 answer

How do I compare two bit vectors for equivalence?

What's the most efficient way to compare two bit vectors? In Objective-C, I'm using CFBitVectors and simply comparing each bit in both: for (CFIndex bitIndex = 0; bitIndex < numBits; bitIndex++) { if (CFBitVectorGetBitAtIndex(thisVector,…
theory
  • 8,210
  • 8
  • 50
  • 115
0
votes
3 answers

Fast way to know compute parity of bitvector

I am working with bitvectors in C. My bitvectors are unsigned long long's. For a large number of vectors I need to know if the parity, i.e. the number of bits that are 1, is even or odd. The exact value is not important, just the parity. I was…
nvcleemp
  • 504
  • 7
  • 18
0
votes
1 answer

How is data stored in a bit vector?

I'm a bit confused how a fixed size bit vector stores its data. Let's assume that we have a bit vector bv that I want to store hello in as ASCII. So we do bv[0]=104, bv[1]=101, bv[2]=108, bv[3]=108, bv[4]=111. How is the ASCII of hello represented…
user1731426
0
votes
1 answer

Check for Nan values in the column of an ND-Array and Remove them

the code below was written to check for NaN values in a Python ND-Array column. If there is a NaN in either temparr1 or temparr2, we remove the corresponding row from both of them. The problem is, it doesn't seem to work. Could you please help me…
gran_profaci
  • 7,133
  • 12
  • 55
  • 94
0
votes
1 answer

What's wrong with my bit vector?

I am trying to create a bit vector backed by an int[]. So I have the following code: public class BitVector { int[] vector = new int[1 << 16]; public void setBit(int nextInt) { nextInt = nextInt & 0xFFFF; int pos = nextInt /…
Cratylus
  • 49,824
  • 60
  • 195
  • 327
-1
votes
1 answer

How to diagnose bizarre behavior of saving and loading a bit vector (std::vector)?

I'm writing a one-off utility to edit a monochrome bitmap format for a game. There are 0x10000 "slots" for 8x8 monochrome sprites. I store each 8x8 sprite in eight bytes, each representing a horizontal line of on- or off-pixels. Everything was fine…
holomenicus
  • 141
  • 5
-1
votes
1 answer

Accessing the output of a Python program

I am using BitVector in Python. I have to perform division over two bit vectors. I have used the code below: from BitVector import* mod = BitVector( bitstring='1011011' ) n = 6 a = BitVector( intVal = 9223372036854775809 ) quotient, remainder =…
-1
votes
1 answer

Read bits from char array

I have a function that takes a buffer of size 2kB and loads certain content to it. I can assume the function works properly, but i can't test it. The function prototype is int loadContent(unsigned long, char* buffer); Unsigned long is the number of…
idjuradj
  • 1,175
  • 5
  • 14
  • 28
-2
votes
3 answers

what is the value of all 32 bits set to 1 in int?

I was experimenting with bit operations in java I tried setting bit index by index and this is what I have got. Started setting with 0 th bit in the integer 0 to 31st bit (as int has got 32 bits max) value of0bits set: 1 value of1bits set:…
Athul Muralidharan
  • 563
  • 1
  • 7
  • 15
-2
votes
1 answer

Specify Very large numbers use in C

I'm thinking of using big large integers one way i can think is using Gmplib, i worked with small examples, but can it work with numbers like 2 ^ (2 ^ (2 ^ 1024)) ?? My question is how to represent that big number because (not sure) calculators too…
user2754673
  • 339
  • 1
  • 12
1 2 3
9
10