Esempio n. 1
0
//A uniqueSet object holds the index in a hashTable to the string representation
//We can take that string, get its index in a cntTable and then set the
//appropriate bit
char *us2char(cntTable *ct, hashTable *ht, uniqueSet *us, int len) {
    char *o = (char *) calloc(len, 1);
    int byte, bit, i, idx;

    for(i=0; i<us->l; i++) {
        idx = str2idx(ct, val2strHT(ht, us->IDs[i]));
        if(idx == -1) continue;
        byte = idx>>3;
        assert(byte<len);
        bit = idx%8;
        o[byte] |= 1<<bit;
    }
    return o;
}
char *us_val(uniqueSet *us, int32_t i) {
    if(i>=us->l) return NULL;
    return val2strHT(us->ht, us->IDs[i]);
}