#NEWLINE# def __setitem__( self , key , value ) : #NEWLINE# #INDENT# if ( key in self . data ) : #NEWLINE# #INDENT# del self [ key ] #NEWLINE# #UNINDENT# obj = LRUNode ( self . tail , key , value ) #NEWLINE# if ( not self . head ) : #NEWLINE# #INDENT# self . head = obj #NEWLINE# #UNINDENT# if self . tail : #NEWLINE# #INDENT# self . tail . next = obj #NEWLINE# #UNINDENT# self . tail = obj #NEWLINE# self . data [ key ] = obj #NEWLINE# if ( len ( self . data ) > self . maximum ) : #NEWLINE# #INDENT# head = self . head #NEWLINE# head . next . prev = None #NEWLINE# self . head = head . next #NEWLINE# head . next = None #NEWLINE# del head . data [ head . key ] #NEWLINE# del head