klao@347: // -*- c++ -*- // klao@347: klao@347: #ifndef HUGO_ITER_MAP klao@347: #define HUGO_ITER_MAP klao@347: klao@347: #include klao@347: #include klao@347: // for uint8_t klao@347: #include klao@347: // for memset klao@347: #include klao@347: klao@347: klao@347: namespace hugo { klao@347: klao@347: klao@347: /// \todo Decide whether we need all the range checkings!!! klao@347: klao@347: template klao@347: class IterableMap { klao@347: public: klao@347: klao@347: typedef typename KeyIntMap::KeyType KeyType; klao@347: typedef uint8_t ValueType; klao@347: klao@347: typedef typename std::vector::const_iterator iterator; klao@347: klao@347: protected: klao@347: KeyIntMap &base; klao@347: std::vector data; klao@347: size_t bounds[N]; klao@347: klao@347: uint8_t find(size_t a) const { klao@347: uint8_t n=0; klao@347: for(; n n) { klao@347: --m; klao@347: half_swap(a, bounds[m]++); klao@347: } klao@347: while(m < n) { klao@347: half_swap(a, --bounds[m]); klao@347: ++m; klao@347: } klao@347: if(a != orig_a) { klao@347: base.set(orig_key, a); klao@347: data[a]=orig_key; klao@347: } klao@347: } klao@347: return a; klao@347: } klao@347: klao@347: public: klao@347: klao@347: IterableMap(KeyIntMap &_base) : base(_base) { klao@347: memset(bounds, 0, sizeof(bounds)); klao@347: // for(int i=0; i