<s> class LRUCache : <EOL> def __init__ ( self , capacity , dispose ) : <EOL> self . _cache = { } <EOL> self . _lru = [ ] <EOL> self . _capacity = capacity <EOL> self . _dispose = dispose <EOL> def __setitem__ ( self , key , value ) : <EOL> assert key not in self . _cache , ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . _lru . append ( key ) <EOL> while len ( self . _lru ) > self . _capacity : <EOL> del self [ self . _lru [ <NUM_LIT:0> ] ] <EOL> self . _cache [ key ] = value <EOL> def __getitem__ ( self , key ) : <EOL> value = self . _cache [ key ] <EOL> self . _lru . remove ( key ) <EOL> self . _lru . append ( key ) <EOL> return value <EOL> def __delitem__ ( self , key ) : <EOL> value = self . _cache . pop ( key ) <EOL> self . _dispose ( value ) <EOL> self . _lru . remove ( key ) <EOL> def __contains__ ( self , key ) : <EOL> return key in self . _cache <EOL> def clear ( self ) : <EOL> for value in self . _cache . values ( ) : <EOL> self . _dispose ( value ) <EOL> self . _cache . clear ( ) <EOL> def items ( self ) : <EOL> return self . _cache . items ( ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _cache ) </s>
