gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Don't assume that the default maps are reference maps (in Elevator)
0 1 0
default
1 file changed with 19 insertions and 17 deletions:
↑ Collapse diff ↑
Ignore white space 8 line context
... ...
@@ -73,25 +73,25 @@
73 73
    int _highest_active;
74 74

	
75 75
    void copy(Item i, Vit p)
76 76
    {
77
      _where[*p=i]=p;
77
      _where.set(*p=i,p);
78 78
    }
79 79
    void copy(Vit s, Vit p)
80 80
    {
81 81
      if(s!=p)
82 82
        {
83 83
          Item i=*s;
84 84
          *p=i;
85
          _where[i]=p;
85
          _where.set(i,p);
86 86
        }
87 87
    }
88 88
    void swap(Vit i, Vit j)
89 89
    {
90 90
      Item ti=*i;
91 91
      Vit ct = _where[ti];
92
      _where[ti]=_where[*i=*j];
93
      _where[*j]=ct;
92
      _where.set(ti,_where[*i=*j]);
93
      _where.set(*j,ct);
94 94
      *j=ti;
95 95
    }
96 96

	
97 97
  public:
... ...
@@ -226,9 +226,10 @@
226 226
    ///Lift the item returned by highestActive() by one.
227 227
    ///
228 228
    void liftHighestActive()
229 229
    {
230
      ++_level[*_last_active[_highest_active]];
230
      Item it = *_last_active[_highest_active];
231
      _level.set(it,_level[it]+1);
231 232
      swap(_last_active[_highest_active]--,_last_active[_highest_active+1]);
232 233
      --_first[++_highest_active];
233 234
    }
234 235

	
... ...
@@ -249,9 +250,9 @@
249 250
          copy(--_first[l+1],_first[l]);
250 251
          --_last_active[l];
251 252
        }
252 253
      copy(li,_first[new_level]);
253
      _level[li]=new_level;
254
      _level.set(li,new_level);
254 255
      _highest_active=new_level;
255 256
    }
256 257

	
257 258
    ///Lift the highest active item.
... ...
@@ -273,9 +274,9 @@
273 274
          --_last_active[l];
274 275
        }
275 276
      copy(li,_first[_max_level]);
276 277
      --_last_active[_max_level];
277
      _level[li]=_max_level;
278
      _level.set(li,_max_level);
278 279

	
279 280
      while(_highest_active>=0 &&
280 281
            _last_active[_highest_active]<_first[_highest_active])
281 282
        _highest_active--;
... ...
@@ -304,9 +305,10 @@
304 305
    ///Lifts the active item returned by \c activeOn() member function
305 306
    ///by one.
306 307
    Item liftActiveOn(int level)
307 308
    {
308
      ++_level[*_last_active[level]];
309
      Item it =*_last_active[level];
310
      _level.set(it,_level[it]+1);
309 311
      swap(_last_active[level]--, --_first[level+1]);
310 312
      if (level+1>_highest_active) ++_highest_active;
311 313
    }
312 314

	
... ...
@@ -324,9 +326,9 @@
324 326
          copy(_last_active[l],_first[l]);
325 327
          copy(--_first[l+1], _last_active[l]--);
326 328
        }
327 329
      copy(ai,_first[new_level]);
328
      _level[ai]=new_level;
330
      _level.set(ai,new_level);
329 331
      if (new_level>_highest_active) _highest_active=new_level;
330 332
    }
331 333

	
332 334
    ///Lifts the active item returned by \c activeOn() member function.
... ...
@@ -344,9 +346,9 @@
344 346
          copy(--_first[l+1], _last_active[l]--);
345 347
        }
346 348
      copy(ai,_first[_max_level]);
347 349
      --_last_active[_max_level];
348
      _level[ai]=_max_level;
350
      _level.set(ai,_max_level);
349 351

	
350 352
      if (_highest_active==level) {
351 353
        while(_highest_active>=0 &&
352 354
              _last_active[_highest_active]<_first[_highest_active])
... ...
@@ -375,9 +377,9 @@
375 377
          copy(_last_active[l],_first[l]);
376 378
          copy(--_first[l+1],_last_active[l]--);
377 379
        }
378 380
      copy(i,_first[new_level]);
379
      _level[i]=new_level;
381
      _level.set(i,new_level);
380 382
      if(new_level>_highest_active) _highest_active=new_level;
381 383
    }
382 384

	
383 385
    ///Move an inactive item to the top but one level (in a dirty way).
... ...
@@ -386,9 +388,9 @@
386 388
    ///It makes the underlying datastructure corrupt, so use is only if
387 389
    ///you really know what it is for.
388 390
    ///\pre The item is on the top level.
389 391
    void dirtyTopButOne(Item i) {
390
      _level[i] = _max_level - 1;
392
      _level.set(i,_max_level - 1);
391 393
    }
392 394

	
393 395
    ///Lift all items on and above a level to the top (and deactivate them).
394 396

	
... ...
@@ -398,9 +400,9 @@
398 400
    {
399 401
      const Vit f=_first[l];
400 402
      const Vit tl=_first[_max_level];
401 403
      for(Vit i=f;i!=tl;++i)
402
        _level[*i]=_max_level;
404
        _level.set(*i,_max_level);
403 405
      for(int i=l;i<=_max_level;i++)
404 406
        {
405 407
          _first[i]=f;
406 408
          _last_active[i]=f-1;
... ...
@@ -439,20 +441,20 @@
439 441
      Vit n=&_items[0];
440 442
      for(typename ItemSetTraits<Graph,Item>::ItemIt i(_g);i!=INVALID;++i)
441 443
        {
442 444
          *n=i;
443
          _where[i]=n;
444
          _level[i]=_max_level;
445
          _where.set(i,n);
446
          _level.set(i,_max_level);
445 447
          ++n;
446 448
        }
447 449
    }
448 450

	
449 451
    ///Add an item to the current level.
450 452

	
451 453
    void initAddItem(Item i)
452 454
    {
453
     swap(_where[i],_init_num);
454
      _level[i]=_init_lev;
455
      swap(_where[i],_init_num);
456
      _level.set(i,_init_lev);
455 457
      ++_init_num;
456 458
    }
457 459

	
458 460
    ///Start a new level.
0 comments (0 inline)