lemon/elevator.h
changeset 599 f63e87b9748e
parent 559 c5fd2d996909
child 1139 d51126dc39fa
     1.1 --- a/lemon/elevator.h	Sat Apr 18 21:54:30 2009 +0200
     1.2 +++ b/lemon/elevator.h	Tue Apr 21 10:34:49 2009 +0100
     1.3 @@ -76,7 +76,7 @@
     1.4  
     1.5      void copy(Item i, Vit p)
     1.6      {
     1.7 -      _where.set(*p=i,p);
     1.8 +      _where[*p=i] = p;
     1.9      }
    1.10      void copy(Vit s, Vit p)
    1.11      {
    1.12 @@ -84,15 +84,15 @@
    1.13          {
    1.14            Item i=*s;
    1.15            *p=i;
    1.16 -          _where.set(i,p);
    1.17 +          _where[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.set(ti,_where[*i=*j]);
    1.25 -      _where.set(*j,ct);
    1.26 +      _where[ti] = _where[*i=*j];
    1.27 +      _where[*j] = ct;
    1.28        *j=ti;
    1.29      }
    1.30  
    1.31 @@ -226,7 +226,7 @@
    1.32      void liftHighestActive()
    1.33      {
    1.34        Item it = *_last_active[_highest_active];
    1.35 -      _level.set(it,_level[it]+1);
    1.36 +      ++_level[it];
    1.37        swap(_last_active[_highest_active]--,_last_active[_highest_active+1]);
    1.38        --_first[++_highest_active];
    1.39      }
    1.40 @@ -249,7 +249,7 @@
    1.41            --_last_active[l];
    1.42          }
    1.43        copy(li,_first[new_level]);
    1.44 -      _level.set(li,new_level);
    1.45 +      _level[li] = new_level;
    1.46        _highest_active=new_level;
    1.47      }
    1.48  
    1.49 @@ -269,7 +269,7 @@
    1.50          }
    1.51        copy(li,_first[_max_level]);
    1.52        --_last_active[_max_level];
    1.53 -      _level.set(li,_max_level);
    1.54 +      _level[li] = _max_level;
    1.55  
    1.56        while(_highest_active>=0 &&
    1.57              _last_active[_highest_active]<_first[_highest_active])
    1.58 @@ -299,7 +299,7 @@
    1.59      Item liftActiveOn(int level)
    1.60      {
    1.61        Item it =*_last_active[level];
    1.62 -      _level.set(it,_level[it]+1);
    1.63 +      ++_level[it];
    1.64        swap(_last_active[level]--, --_first[level+1]);
    1.65        if (level+1>_highest_active) ++_highest_active;
    1.66      }
    1.67 @@ -319,7 +319,7 @@
    1.68            copy(--_first[l+1], _last_active[l]--);
    1.69          }
    1.70        copy(ai,_first[new_level]);
    1.71 -      _level.set(ai,new_level);
    1.72 +      _level[ai] = new_level;
    1.73        if (new_level>_highest_active) _highest_active=new_level;
    1.74      }
    1.75  
    1.76 @@ -339,7 +339,7 @@
    1.77          }
    1.78        copy(ai,_first[_max_level]);
    1.79        --_last_active[_max_level];
    1.80 -      _level.set(ai,_max_level);
    1.81 +      _level[ai] = _max_level;
    1.82  
    1.83        if (_highest_active==level) {
    1.84          while(_highest_active>=0 &&
    1.85 @@ -370,7 +370,7 @@
    1.86            copy(--_first[l+1],_last_active[l]--);
    1.87          }
    1.88        copy(i,_first[new_level]);
    1.89 -      _level.set(i,new_level);
    1.90 +      _level[i] = new_level;
    1.91        if(new_level>_highest_active) _highest_active=new_level;
    1.92      }
    1.93  
    1.94 @@ -382,7 +382,7 @@
    1.95      ///only if you really know what it is for.
    1.96      ///\pre The item is on the top level.
    1.97      void dirtyTopButOne(Item i) {
    1.98 -      _level.set(i,_max_level - 1);
    1.99 +      _level[i] = _max_level - 1;
   1.100      }
   1.101  
   1.102      ///Lift all items on and above the given level to the top level.
   1.103 @@ -394,7 +394,7 @@
   1.104        const Vit f=_first[l];
   1.105        const Vit tl=_first[_max_level];
   1.106        for(Vit i=f;i!=tl;++i)
   1.107 -        _level.set(*i,_max_level);
   1.108 +        _level[*i] = _max_level;
   1.109        for(int i=l;i<=_max_level;i++)
   1.110          {
   1.111            _first[i]=f;
   1.112 @@ -433,8 +433,8 @@
   1.113        for(typename ItemSetTraits<GR,Item>::ItemIt i(_g);i!=INVALID;++i)
   1.114          {
   1.115            *n=i;
   1.116 -          _where.set(i,n);
   1.117 -          _level.set(i,_max_level);
   1.118 +          _where[i] = n;
   1.119 +          _level[i] = _max_level;
   1.120            ++n;
   1.121          }
   1.122      }
   1.123 @@ -443,7 +443,7 @@
   1.124      void initAddItem(Item i)
   1.125      {
   1.126        swap(_where[i],_init_num);
   1.127 -      _level.set(i,_init_lev);
   1.128 +      _level[i] = _init_lev;
   1.129        ++_init_num;
   1.130      }
   1.131  
   1.132 @@ -551,7 +551,7 @@
   1.133      ///Activate item \c i.
   1.134      ///\pre Item \c i shouldn't be active before.
   1.135      void activate(Item i) {
   1.136 -      _active.set(i, true);
   1.137 +      _active[i] = true;
   1.138  
   1.139        int level = _level[i];
   1.140        if (level > _highest_active) {
   1.141 @@ -560,16 +560,16 @@
   1.142  
   1.143        if (_prev[i] == INVALID || _active[_prev[i]]) return;
   1.144        //unlace
   1.145 -      _next.set(_prev[i], _next[i]);
   1.146 +      _next[_prev[i]] = _next[i];
   1.147        if (_next[i] != INVALID) {
   1.148 -        _prev.set(_next[i], _prev[i]);
   1.149 +        _prev[_next[i]] = _prev[i];
   1.150        } else {
   1.151          _last[level] = _prev[i];
   1.152        }
   1.153        //lace
   1.154 -      _next.set(i, _first[level]);
   1.155 -      _prev.set(_first[level], i);
   1.156 -      _prev.set(i, INVALID);
   1.157 +      _next[i] = _first[level];
   1.158 +      _prev[_first[level]] = i;
   1.159 +      _prev[i] = INVALID;
   1.160        _first[level] = i;
   1.161  
   1.162      }
   1.163 @@ -579,23 +579,23 @@
   1.164      ///Deactivate item \c i.
   1.165      ///\pre Item \c i must be active before.
   1.166      void deactivate(Item i) {
   1.167 -      _active.set(i, false);
   1.168 +      _active[i] = false;
   1.169        int level = _level[i];
   1.170  
   1.171        if (_next[i] == INVALID || !_active[_next[i]])
   1.172          goto find_highest_level;
   1.173  
   1.174        //unlace
   1.175 -      _prev.set(_next[i], _prev[i]);
   1.176 +      _prev[_next[i]] = _prev[i];
   1.177        if (_prev[i] != INVALID) {
   1.178 -        _next.set(_prev[i], _next[i]);
   1.179 +        _next[_prev[i]] = _next[i];
   1.180        } else {
   1.181          _first[_level[i]] = _next[i];
   1.182        }
   1.183        //lace
   1.184 -      _prev.set(i, _last[level]);
   1.185 -      _next.set(_last[level], i);
   1.186 -      _next.set(i, INVALID);
   1.187 +      _prev[i] = _last[level];
   1.188 +      _next[_last[level]] = i;
   1.189 +      _next[i] = INVALID;
   1.190        _last[level] = i;
   1.191  
   1.192      find_highest_level:
   1.193 @@ -685,21 +685,21 @@
   1.194      void liftHighestActive() {
   1.195        Item i = _first[_highest_active];
   1.196        if (_next[i] != INVALID) {
   1.197 -        _prev.set(_next[i], INVALID);
   1.198 +        _prev[_next[i]] = INVALID;
   1.199          _first[_highest_active] = _next[i];
   1.200        } else {
   1.201          _first[_highest_active] = INVALID;
   1.202          _last[_highest_active] = INVALID;
   1.203        }
   1.204 -      _level.set(i, ++_highest_active);
   1.205 +      _level[i] = ++_highest_active;
   1.206        if (_first[_highest_active] == INVALID) {
   1.207          _first[_highest_active] = i;
   1.208          _last[_highest_active] = i;
   1.209 -        _prev.set(i, INVALID);
   1.210 -        _next.set(i, INVALID);
   1.211 +        _prev[i] = INVALID;
   1.212 +        _next[i] = INVALID;
   1.213        } else {
   1.214 -        _prev.set(_first[_highest_active], i);
   1.215 -        _next.set(i, _first[_highest_active]);
   1.216 +        _prev[_first[_highest_active]] = i;
   1.217 +        _next[i] = _first[_highest_active];
   1.218          _first[_highest_active] = i;
   1.219        }
   1.220      }
   1.221 @@ -714,20 +714,20 @@
   1.222      void liftHighestActive(int new_level) {
   1.223        Item i = _first[_highest_active];
   1.224        if (_next[i] != INVALID) {
   1.225 -        _prev.set(_next[i], INVALID);
   1.226 +        _prev[_next[i]] = INVALID;
   1.227          _first[_highest_active] = _next[i];
   1.228        } else {
   1.229          _first[_highest_active] = INVALID;
   1.230          _last[_highest_active] = INVALID;
   1.231        }
   1.232 -      _level.set(i, _highest_active = new_level);
   1.233 +      _level[i] = _highest_active = new_level;
   1.234        if (_first[_highest_active] == INVALID) {
   1.235          _first[_highest_active] = _last[_highest_active] = i;
   1.236 -        _prev.set(i, INVALID);
   1.237 -        _next.set(i, INVALID);
   1.238 +        _prev[i] = INVALID;
   1.239 +        _next[i] = INVALID;
   1.240        } else {
   1.241 -        _prev.set(_first[_highest_active], i);
   1.242 -        _next.set(i, _first[_highest_active]);
   1.243 +        _prev[_first[_highest_active]] = i;
   1.244 +        _next[i] = _first[_highest_active];
   1.245          _first[_highest_active] = i;
   1.246        }
   1.247      }
   1.248 @@ -738,9 +738,9 @@
   1.249      ///deactivate it.
   1.250      void liftHighestActiveToTop() {
   1.251        Item i = _first[_highest_active];
   1.252 -      _level.set(i, _max_level);
   1.253 +      _level[i] = _max_level;
   1.254        if (_next[i] != INVALID) {
   1.255 -        _prev.set(_next[i], INVALID);
   1.256 +        _prev[_next[i]] = INVALID;
   1.257          _first[_highest_active] = _next[i];
   1.258        } else {
   1.259          _first[_highest_active] = INVALID;
   1.260 @@ -774,20 +774,20 @@
   1.261      {
   1.262        Item i = _first[l];
   1.263        if (_next[i] != INVALID) {
   1.264 -        _prev.set(_next[i], INVALID);
   1.265 +        _prev[_next[i]] = INVALID;
   1.266          _first[l] = _next[i];
   1.267        } else {
   1.268          _first[l] = INVALID;
   1.269          _last[l] = INVALID;
   1.270        }
   1.271 -      _level.set(i, ++l);
   1.272 +      _level[i] = ++l;
   1.273        if (_first[l] == INVALID) {
   1.274          _first[l] = _last[l] = i;
   1.275 -        _prev.set(i, INVALID);
   1.276 -        _next.set(i, INVALID);
   1.277 +        _prev[i] = INVALID;
   1.278 +        _next[i] = INVALID;
   1.279        } else {
   1.280 -        _prev.set(_first[l], i);
   1.281 -        _next.set(i, _first[l]);
   1.282 +        _prev[_first[l]] = i;
   1.283 +        _next[i] = _first[l];
   1.284          _first[l] = i;
   1.285        }
   1.286        if (_highest_active < l) {
   1.287 @@ -803,20 +803,20 @@
   1.288      {
   1.289        Item i = _first[l];
   1.290        if (_next[i] != INVALID) {
   1.291 -        _prev.set(_next[i], INVALID);
   1.292 +        _prev[_next[i]] = INVALID;
   1.293          _first[l] = _next[i];
   1.294        } else {
   1.295          _first[l] = INVALID;
   1.296          _last[l] = INVALID;
   1.297        }
   1.298 -      _level.set(i, l = new_level);
   1.299 +      _level[i] = l = new_level;
   1.300        if (_first[l] == INVALID) {
   1.301          _first[l] = _last[l] = i;
   1.302 -        _prev.set(i, INVALID);
   1.303 -        _next.set(i, INVALID);
   1.304 +        _prev[i] = INVALID;
   1.305 +        _next[i] = INVALID;
   1.306        } else {
   1.307 -        _prev.set(_first[l], i);
   1.308 -        _next.set(i, _first[l]);
   1.309 +        _prev[_first[l]] = i;
   1.310 +        _next[i] = _first[l];
   1.311          _first[l] = i;
   1.312        }
   1.313        if (_highest_active < l) {
   1.314 @@ -832,13 +832,13 @@
   1.315      {
   1.316        Item i = _first[l];
   1.317        if (_next[i] != INVALID) {
   1.318 -        _prev.set(_next[i], INVALID);
   1.319 +        _prev[_next[i]] = INVALID;
   1.320          _first[l] = _next[i];
   1.321        } else {
   1.322          _first[l] = INVALID;
   1.323          _last[l] = INVALID;
   1.324        }
   1.325 -      _level.set(i, _max_level);
   1.326 +      _level[i] = _max_level;
   1.327        if (l == _highest_active) {
   1.328          while (_highest_active >= 0 && activeFree(_highest_active))
   1.329            --_highest_active;
   1.330 @@ -856,23 +856,23 @@
   1.331      ///
   1.332      void lift(Item i, int new_level) {
   1.333        if (_next[i] != INVALID) {
   1.334 -        _prev.set(_next[i], _prev[i]);
   1.335 +        _prev[_next[i]] = _prev[i];
   1.336        } else {
   1.337          _last[new_level] = _prev[i];
   1.338        }
   1.339        if (_prev[i] != INVALID) {
   1.340 -        _next.set(_prev[i], _next[i]);
   1.341 +        _next[_prev[i]] = _next[i];
   1.342        } else {
   1.343          _first[new_level] = _next[i];
   1.344        }
   1.345 -      _level.set(i, new_level);
   1.346 +      _level[i] = new_level;
   1.347        if (_first[new_level] == INVALID) {
   1.348          _first[new_level] = _last[new_level] = i;
   1.349 -        _prev.set(i, INVALID);
   1.350 -        _next.set(i, INVALID);
   1.351 +        _prev[i] = INVALID;
   1.352 +        _next[i] = INVALID;
   1.353        } else {
   1.354 -        _prev.set(_first[new_level], i);
   1.355 -        _next.set(i, _first[new_level]);
   1.356 +        _prev[_first[new_level]] = i;
   1.357 +        _next[i] = _first[new_level];
   1.358          _first[new_level] = i;
   1.359        }
   1.360        if (_highest_active < new_level) {
   1.361 @@ -888,7 +888,7 @@
   1.362      ///only if you really know what it is for.
   1.363      ///\pre The item is on the top level.
   1.364      void dirtyTopButOne(Item i) {
   1.365 -      _level.set(i, _max_level - 1);
   1.366 +      _level[i] = _max_level - 1;
   1.367      }
   1.368  
   1.369      ///Lift all items on and above the given level to the top level.
   1.370 @@ -899,7 +899,7 @@
   1.371        for (int i = l + 1; _first[i] != INVALID; ++i) {
   1.372          Item n = _first[i];
   1.373          while (n != INVALID) {
   1.374 -          _level.set(n, _max_level);
   1.375 +          _level[n] = _max_level;
   1.376            n = _next[n];
   1.377          }
   1.378          _first[i] = INVALID;
   1.379 @@ -937,23 +937,23 @@
   1.380        _init_level = 0;
   1.381        for(typename ItemSetTraits<GR,Item>::ItemIt i(_graph);
   1.382            i != INVALID; ++i) {
   1.383 -        _level.set(i, _max_level);
   1.384 -        _active.set(i, false);
   1.385 +        _level[i] = _max_level;
   1.386 +        _active[i] = false;
   1.387        }
   1.388      }
   1.389  
   1.390      ///Add an item to the current level.
   1.391      void initAddItem(Item i) {
   1.392 -      _level.set(i, _init_level);
   1.393 +      _level[i] = _init_level;
   1.394        if (_last[_init_level] == INVALID) {
   1.395          _first[_init_level] = i;
   1.396          _last[_init_level] = i;
   1.397 -        _prev.set(i, INVALID);
   1.398 -        _next.set(i, INVALID);
   1.399 +        _prev[i] = INVALID;
   1.400 +        _next[i] = INVALID;
   1.401        } else {
   1.402 -        _prev.set(i, _last[_init_level]);
   1.403 -        _next.set(i, INVALID);
   1.404 -        _next.set(_last[_init_level], i);
   1.405 +        _prev[i] = _last[_init_level];
   1.406 +        _next[i] = INVALID;
   1.407 +        _next[_last[_init_level]] = i;
   1.408          _last[_init_level] = i;
   1.409        }
   1.410      }