Demo directory...
    13 #include <hugo/invalid.h>
 
    17   /// \brief A map with "small integers" as value set which can enumarate it
 
    20   /// \todo Decide whether we need all the range checkings!!!
 
    22   /// \todo Implement dynamic map behaviour. Is it necessary? Yes it is.
 
    24   template<typename KeyIntMap, uint8_t N, typename Val = uint8_t>
 
    28     typedef typename KeyIntMap::KeyType KeyType;
 
    29     typedef Val ValueType;
 
    31     typedef typename std::vector<KeyType>::const_iterator iterator;
 
    35     std::vector<KeyType> data;
 
    39     Val find(size_t a) const {
 
    40       for(uint8_t n=0; n<N; ++n) {
 
    47     void half_swap(size_t &a, size_t b) {
 
    55     size_t move(size_t a, uint8_t m, uint8_t n) {
 
    58 	KeyType orig_key = data[a];
 
    61 	  half_swap(a, bounds[m]++);
 
    63 	// FIXME: range check ide?
 
    65 	  half_swap(a, --bounds[m]);
 
    69 	  base.set(orig_key, a);
 
    78     IterableMap(KeyIntMap &_base, Val d = N+1) : base(_base), def_val(d) {
 
    79       memset(bounds, 0, sizeof(bounds));
 
    80       //    for(int i=0; i<N; ++i) { bounds[i]=0; }
 
    83     Val operator[](const KeyType& k) const {
 
    87     void set(const KeyType& k, Val n) {
 
    88       // FIXME: range check?
 
    98     void insert(const KeyType& k, Val n) {
 
   100       base.set(k, move(bounds[N-1]++, N-1, n));
 
   103     /// This func is not very usable, but necessary to implement 
 
   104     /// dynamic map behaviour.
 
   105     void remove(const KeyType& k) {
 
   107       if(a < bounds[N-1]) {
 
   114     iterator begin(Val n) const {
 
   115       return data.begin() + (n ? bounds[n-1] : 0);
 
   118     iterator end(Val n) const {
 
   119       return data.begin() + bounds[n];
 
   122     size_t size(Val n) const {
 
   123       return bounds[n] - (n ? bounds[n-1] : 0);
 
   126     size_t size() const {
 
   127       // assert(bounds[N-1] == data.size());
 
   132     /// For use as an iterator...
 
   133     KeyType& first(KeyType &k, Val n) {
 
   134       size_t i = (n ? bounds[n-1] : 0);
 
   135       if( i < bounds[n] ) {
 
   144     /// For use as an iterator...
 
   145     KeyType& next(KeyType &k) {
 
   149       if( i < bounds[n] ) {
 
   163   template<typename KeyIntMap>
 
   164   class IterableBoolMap : public IterableMap<KeyIntMap, 2, bool> {
 
   165     typedef IterableMap<KeyIntMap, 2, bool> Parent;
 
   168     IterableBoolMap(KeyIntMap &_base, bool d = false) : Parent(_base, d) {}