17 /// \todo Decide whether we need all the range checkings!!!
19 template<typename KeyIntMap, uint8_t N>
23 typedef typename KeyIntMap::KeyType KeyType;
24 typedef uint8_t ValueType;
26 typedef typename std::vector<KeyType>::const_iterator iterator;
30 std::vector<KeyType> data;
33 uint8_t find(size_t a) const {
35 for(; n<N && bounds[n]<=a; ++n);
39 void half_swap(size_t &a, size_t b) {
47 size_t move(size_t a, uint8_t m, uint8_t n) {
50 KeyType orig_key = data[a];
53 half_swap(a, bounds[m]++);
56 half_swap(a, --bounds[m]);
60 base.set(orig_key, a);
69 IterableMap(KeyIntMap &_base) : base(_base) {
70 memset(bounds, 0, sizeof(bounds));
71 // for(int i=0; i<N; ++i) { bounds[i]=0; }
74 uint8_t operator[](const KeyType& k) const {
78 void set(const KeyType& k, uint8_t n) {
81 base.set(k, move(a, find(a), n));
85 void insert(const KeyType& k, uint8_t n) {
88 base.set(k, move(bounds[N-1]++, N-1, n));
92 iterator begin(uint8_t n) const {
94 return data.begin() + (n ? bounds[n-1] : 0);
99 iterator end(uint8_t n) const {
101 return data.begin() + bounds[n];
106 size_t size(uint8_t n) const {
108 return bounds[n] - (n ? bounds[n-1] : 0);
113 size_t size() const {
114 // assert(bounds[N-1] == data.size());