Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "byte_dict.h"
- byte_dict::byte_dict(){};
- int byte_dict::fill(bits b, int index)
- {
- for (int i=0; i<b.size-7; ++i)
- {
- dict[get_byte(b.b.begin(), i)].insert(index+i);
- }
- load+=b.size-7;
- return b.size-7;
- };
- std::unordered_set<int> byte_dict::get(byte b)
- {
- return dict[b];
- };
- int byte_dict::remove(int min)
- {
- int count=0;
- for (int i=0; i<256; ++i)
- {
- for (auto h: dict[i])
- {
- if (h<min)
- {
- dict[i].erase(h);
- count++;
- }
- }
- }
- load-=count;
- return count;
- };
- int byte_dict::update(int offset)
- {
- std::vector<int> tempv;
- load=0;
- for (int i=0; i<256; ++i)
- {
- for (auto h: dict[i])
- {
- int temp=h-offset;
- if(temp>=0)
- {
- tempv.push_back(temp);
- ++load;
- }
- }
- dict[i].clear();
- dict[i].insert(tempv.begin(), tempv.end());
- tempv.clear();
- }
- return load;
- };
- int byte_dict::size()
- {
- return load;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement