예제 #1
0
파일: wt.hpp 프로젝트: tb37/sdsl-lite
    static size_type alphabet_size_and_map(const reference_type rac, size_type n, map_type& map, inv_map_type& inv_map, value_type& first_symbol) {
        map.clear();
        inv_map.clear();
        if (n==0) {
            for (size_type i=0; i<256; ++i) {
                map[i] = 255;    // mark each symbol as absent
            }
            return 0;
        }
        first_symbol    = *rac;
        map[*rac] = 0;
        inv_map[0] = *rac;
        size_type alphabet_size = 0;

        for (size_type i=0; i<256; ++i) {
            map[i] = 0;
        }

        for (size_type i=0; i<n; ++i) {
            value_type c = *(rac+i);
            map[c] = 1;
        }

        for (size_type i=0; i<256; ++i) {
            if (map[i]) {
                map[i] = alphabet_size;
                ++alphabet_size;
            } else {
                map[i] = 255;
            }
            inv_map[map[i]] = i;
        }
        return alphabet_size;
    }
예제 #2
0
파일: mapper.cpp 프로젝트: ajalkane/rvhouse
void
mapper::_free_map(map_type &m) {
    map_type::iterator i = m.begin();
    for (; i != m.end(); i++) {
        if (i->first)  free((void *)i->first);
        if (i->second) free((void *)i->second);
    }
    m.clear();
}
예제 #3
0
파일: wt.hpp 프로젝트: tb37/sdsl-lite
 static size_type alphabet_size_and_map(const reference_type rac, size_type n, map_type& map, inv_map_type& inv_map, value_type& first_symbol) {
     if (n > 0)
         first_symbol = rac[0];
     map.clear();
     inv_map.clear();
     size_type alphabet_size = 0;
     for (size_type i=0; i<n; ++i) {
         if (map.find(rac[i]) == map.end()) {
             map[rac[i]]    = 1;
         }
     }
     for (typename map_type::iterator it = map.begin(); it != map.end(); ++it) { // this preserves the order
         it->second = alphabet_size;
         inv_map[alphabet_size] = it->first;
         ++alphabet_size;
     }
     return alphabet_size;
 }
예제 #4
0
파일: wt.hpp 프로젝트: tb37/sdsl-lite
    static size_type alphabet_size_and_map(reference_type rac, size_type n, map_type& map, inv_map_type& inv_map, value_type& first_symbol) {
        map.clear();
        inv_map.clear();
        if (n==0) {
            for (size_type i=0; i<256; ++i) {
                map[i] = 255;    // mark each symbol as absent
            }
            return 0;
        }
        if (rac.size() < n) {
            throw std::logic_error("wt<int_vector_buffer<8> >: n > rac.size()!");
            return 0;
        }

        for (size_type i=0; i<256; ++i) {
            map[i] = 0;
        }

        size_type alphabet_size = 0;
        first_symbol = rac[0];
        for (size_type i=0; i < n; ++i) {
            value_type c = rac[i];
            map[c] = 1;
        }

        for (size_type i=0; i<256; ++i) {
            if (map[i]) {
                map[i] = alphabet_size;
                ++alphabet_size;
            } else {
                map[i] = 255;
            }
            inv_map[map[i]] = i;
        }
        return alphabet_size;
    }
예제 #5
0
 inline void clear_factories()
 {
     factories.clear();
 }
예제 #6
0
 inline ~impl()
 {
     factories.clear();
 }