how exactly would I check whether or not a given "item" in a bitset vector is out of bounds
eg:
struct bitset {
unsigned char*vector;
int byteSize;
int bitSize;
};
// create a new, empty bit vector set of 'size' items
struct bitset * bitset_new(int size) {
struct bitset * theSet;
theSet = malloc(sizeof(struct bitset));
theSet->vector = calloc(size, sizeof(char));
theSet->bitSize = size;
theSet->byteSize= ((size / 8) + 1);
return theSet;
}
int bitset_find(struct bitset * this, int k)
{
int arrayIndex = k/8;
int indexPosition = k%8;
unsigned int flag = 1; // flag = 0000.....00001
flag = flag << indexPosition; // flag = 0000...010...000 (shifted k positions)
if()
{
}
}
What exactly should I have in my if statement to see if k is not in my vector?