Don't assume that the default maps are reference maps (in Elevator)
authorAlpar Juttner <alpar@cs.elte.hu>
Fri, 21 Nov 2008 10:41:36 +0000
changeset 39761fbd77f0f44
parent 396 b04e431907bc
child 398 a8a22a96d495
Don't assume that the default maps are reference maps (in Elevator)
lemon/elevator.h
     1.1 --- a/lemon/elevator.h	Mon Nov 17 15:41:15 2008 +0000
     1.2 +++ b/lemon/elevator.h	Fri Nov 21 10:41:36 2008 +0000
     1.3 @@ -74,7 +74,7 @@
     1.4  
     1.5      void copy(Item i, Vit p)
     1.6      {
     1.7 -      _where[*p=i]=p;
     1.8 +      _where.set(*p=i,p);
     1.9      }
    1.10      void copy(Vit s, Vit p)
    1.11      {
    1.12 @@ -82,15 +82,15 @@
    1.13          {
    1.14            Item i=*s;
    1.15            *p=i;
    1.16 -          _where[i]=p;
    1.17 +          _where.set(i,p);
    1.18          }
    1.19      }
    1.20      void swap(Vit i, Vit j)
    1.21      {
    1.22        Item ti=*i;
    1.23        Vit ct = _where[ti];
    1.24 -      _where[ti]=_where[*i=*j];
    1.25 -      _where[*j]=ct;
    1.26 +      _where.set(ti,_where[*i=*j]);
    1.27 +      _where.set(*j,ct);
    1.28        *j=ti;
    1.29      }
    1.30  
    1.31 @@ -227,7 +227,8 @@
    1.32      ///
    1.33      void liftHighestActive()
    1.34      {
    1.35 -      ++_level[*_last_active[_highest_active]];
    1.36 +      Item it = *_last_active[_highest_active];
    1.37 +      _level.set(it,_level[it]+1);
    1.38        swap(_last_active[_highest_active]--,_last_active[_highest_active+1]);
    1.39        --_first[++_highest_active];
    1.40      }
    1.41 @@ -250,7 +251,7 @@
    1.42            --_last_active[l];
    1.43          }
    1.44        copy(li,_first[new_level]);
    1.45 -      _level[li]=new_level;
    1.46 +      _level.set(li,new_level);
    1.47        _highest_active=new_level;
    1.48      }
    1.49  
    1.50 @@ -274,7 +275,7 @@
    1.51          }
    1.52        copy(li,_first[_max_level]);
    1.53        --_last_active[_max_level];
    1.54 -      _level[li]=_max_level;
    1.55 +      _level.set(li,_max_level);
    1.56  
    1.57        while(_highest_active>=0 &&
    1.58              _last_active[_highest_active]<_first[_highest_active])
    1.59 @@ -305,7 +306,8 @@
    1.60      ///by one.
    1.61      Item liftActiveOn(int level)
    1.62      {
    1.63 -      ++_level[*_last_active[level]];
    1.64 +      Item it =*_last_active[level];
    1.65 +      _level.set(it,_level[it]+1);
    1.66        swap(_last_active[level]--, --_first[level+1]);
    1.67        if (level+1>_highest_active) ++_highest_active;
    1.68      }
    1.69 @@ -325,7 +327,7 @@
    1.70            copy(--_first[l+1], _last_active[l]--);
    1.71          }
    1.72        copy(ai,_first[new_level]);
    1.73 -      _level[ai]=new_level;
    1.74 +      _level.set(ai,new_level);
    1.75        if (new_level>_highest_active) _highest_active=new_level;
    1.76      }
    1.77  
    1.78 @@ -345,7 +347,7 @@
    1.79          }
    1.80        copy(ai,_first[_max_level]);
    1.81        --_last_active[_max_level];
    1.82 -      _level[ai]=_max_level;
    1.83 +      _level.set(ai,_max_level);
    1.84  
    1.85        if (_highest_active==level) {
    1.86          while(_highest_active>=0 &&
    1.87 @@ -376,7 +378,7 @@
    1.88            copy(--_first[l+1],_last_active[l]--);
    1.89          }
    1.90        copy(i,_first[new_level]);
    1.91 -      _level[i]=new_level;
    1.92 +      _level.set(i,new_level);
    1.93        if(new_level>_highest_active) _highest_active=new_level;
    1.94      }
    1.95  
    1.96 @@ -387,7 +389,7 @@
    1.97      ///you really know what it is for.
    1.98      ///\pre The item is on the top level.
    1.99      void dirtyTopButOne(Item i) {
   1.100 -      _level[i] = _max_level - 1;
   1.101 +      _level.set(i,_max_level - 1);
   1.102      }
   1.103  
   1.104      ///Lift all items on and above a level to the top (and deactivate them).
   1.105 @@ -399,7 +401,7 @@
   1.106        const Vit f=_first[l];
   1.107        const Vit tl=_first[_max_level];
   1.108        for(Vit i=f;i!=tl;++i)
   1.109 -        _level[*i]=_max_level;
   1.110 +        _level.set(*i,_max_level);
   1.111        for(int i=l;i<=_max_level;i++)
   1.112          {
   1.113            _first[i]=f;
   1.114 @@ -440,8 +442,8 @@
   1.115        for(typename ItemSetTraits<Graph,Item>::ItemIt i(_g);i!=INVALID;++i)
   1.116          {
   1.117            *n=i;
   1.118 -          _where[i]=n;
   1.119 -          _level[i]=_max_level;
   1.120 +          _where.set(i,n);
   1.121 +          _level.set(i,_max_level);
   1.122            ++n;
   1.123          }
   1.124      }
   1.125 @@ -450,8 +452,8 @@
   1.126  
   1.127      void initAddItem(Item i)
   1.128      {
   1.129 -     swap(_where[i],_init_num);
   1.130 -      _level[i]=_init_lev;
   1.131 +      swap(_where[i],_init_num);
   1.132 +      _level.set(i,_init_lev);
   1.133        ++_init_num;
   1.134      }
   1.135