lemon/elevator.h
changeset 2378 c479eab00a18
parent 2352 5e273e0bd5e2
child 2391 14a343be7a5a
equal deleted inserted replaced
5:778167aaab2b 6:d352b0d99c0a
   144       _highest_active(-1)
   144       _highest_active(-1)
   145     {
   145     {
   146     }
   146     }
   147   
   147   
   148     ///Activate item \c i.
   148     ///Activate item \c i.
       
   149 
       
   150     ///Activate item \c i.
       
   151     ///\pre Item \c i shouldn't be active before.
   149     void activate(Item i)
   152     void activate(Item i)
   150     {
   153     {
   151       const int l=_level[i];
   154       const int l=_level[i];
   152       swap(_where[i],++_last_active[l]);
   155       swap(_where[i],++_last_active[l]);
   153       if(l>_highest_active) _highest_active=l;
   156       if(l>_highest_active) _highest_active=l;
   154     }
   157     }
   155   
   158   
   156     ///Deactivate item \c i.
   159     ///Deactivate item \c i.
       
   160 
       
   161     ///Deactivate item \c i.
       
   162     ///\pre Item \c i must be active before.
   157     void deactivate(Item i)  
   163     void deactivate(Item i)  
   158     {
   164     {
   159       swap(_where[i],_last_active[_level[i]]--);
   165       swap(_where[i],_last_active[_level[i]]--);
   160       while(_highest_active>=0 &&
   166       while(_highest_active>=0 &&
   161 	    _last_active[_highest_active]<_first[_highest_active])
   167 	    _last_active[_highest_active]<_first[_highest_active])