Masks and Bits

Hello, I'm having troubles with an algorithm problem, I need to insert a mask inside a "block of bits" declared like this inside a class:
(below "using namespace std;")
1
2
typedef unsigned long block_t;
typedef unsigned char item_t; /*This is meant to be saving the set's content*/

(and in "private attributes")
 
block_t block_;

Then I need to move bits to the left "i" times inside the block (included in function)
 
void set_union(item_t i);

and insert the "i" number inside of that block in the place specified.
And finally make a "logic or" with the "called set" (I think it's saying the item_t one)

By the way, the mask was declared like this below "using namespace std;"
 
#define ONE_MASK 0x01 /*It represents the less significative bit to 1*/ 


The original formulation: (spanish)

El primero inserta un único elemento dentro del conjunto. Para ello
Se debe crear un bloque auxiliar conteniendo la máscara ONE_MASK y
hacer un desplazamiento de bits a la izquierda tantas veces como
indique el elemento a insertar. Después se efectuará el or lógico con
el conjunto llamante.

Topic archived. No new replies allowed.