view regexParser/bitVector.cc @ 296:28c695dac305

Todo
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 02 Feb 2016 11:50:33 +0900
parents 02031fb73af8
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "regexParser.h"

BitVector createBitVector(int state) {
    unsigned long tmp = 1 << state;
    BitVector bi1 = (BitVector){.bitContainer = tmp};
    return bi1;
}

BitVector bitSet(BitVector bi, int bitSetPosition) {
    unsigned long tmp = 1 << bitSetPosition;
    BitVector bi1 = (BitVector){.bitContainer = bi.bitContainer | tmp};
    return bi1;
}

void bitPrint(BitVector bi) {
    unsigned long vec = bi.bitContainer;
    for (int j = 0; j < BITBLOCK; j++) {
        putchar((vec & 1) ? '1':'0');
        vec >>= 1;
    }
    printf("\n");
}