parameters: (self, timestamp, price)
docstring: :type timestamp: int
          :type price: int
          :rtype: None
docstring_summary: :type timestamp: int
          :type price: int
          :rtype: None
docstring_tokens: : type timestamp : int : type price : int : rtype : None
function: def update(self, timestamp, price):
          """
          :type timestamp: int
          :type price: int
          :rtype: None
          """
          def full_delete(heap, sign):  # Time: O(n), Space: O(n)
              heap[:] = [x for x in set(heap) if sign*x[0] == self.__lookup[x[1]]]
              heapq.heapify(heap)
  
          if timestamp > self.__curr:
              self.__curr = timestamp
          self.__lookup[timestamp] = price
          heapq.heappush(self.__min_heap, (price, timestamp))
          heapq.heappush(self.__max_heap, (-price, timestamp))
          if len(self.__min_heap) > 2*len(self.__lookup):  # avoid too much expired or duplicated data
              full_delete(self.__min_heap, 1)
              full_delete(self.__max_heap, -1)
function_tokens: def update ( self , timestamp , price ) : def full_delete ( heap , sign ) : # Time: O(n), Space: O(n) heap [ : ] = [ x for x in set ( heap ) if sign * x [ 0 ] == self . __lookup [ x [ 1 ] ] ] heapq . heapify ( heap ) if timestamp > self . __curr : self . __curr = timestamp self . __lookup [ timestamp ] = price heapq . heappush ( self . __min_heap , ( price , timestamp ) ) heapq . heappush ( self . __max_heap , ( - price , timestamp ) ) if len ( self . __min_heap ) > 2 * len ( self . __lookup ) : # avoid too much expired or duplicated data full_delete ( self . __min_heap , 1 ) full_delete ( self . __max_heap , - 1 )