diff -r 538ff3ce9f68 -r e4ab32225f1c src/work/klao/iter_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/klao/iter_map.h Sat Apr 17 01:57:48 2004 +0000 @@ -0,0 +1,121 @@ +// -*- c++ -*- // + +#ifndef HUGO_ITER_MAP +#define HUGO_ITER_MAP + +#include +#include +// for uint8_t +#include +// for memset +#include + + +namespace hugo { + + + /// \todo Decide whether we need all the range checkings!!! + + template + class IterableMap { + public: + + typedef typename KeyIntMap::KeyType KeyType; + typedef uint8_t ValueType; + + typedef typename std::vector::const_iterator iterator; + + protected: + KeyIntMap &base; + std::vector data; + size_t bounds[N]; + + uint8_t find(size_t a) const { + uint8_t n=0; + for(; n n) { + --m; + half_swap(a, bounds[m]++); + } + while(m < n) { + half_swap(a, --bounds[m]); + ++m; + } + if(a != orig_a) { + base.set(orig_key, a); + data[a]=orig_key; + } + } + return a; + } + + public: + + IterableMap(KeyIntMap &_base) : base(_base) { + memset(bounds, 0, sizeof(bounds)); + // for(int i=0; i