@@ -69,17 +69,17 @@ def getNewsFeed(self, userId):
69
69
"""
70
70
max_heap = []
71
71
if self .__messages [userId ]:
72
- heapq .heappush (max_heap , (- self .__messages [userId ][- 1 ][0 ], userId , 0 , len ( self . __messages [ userId ]) ))
72
+ heapq .heappush (max_heap , (- self .__messages [userId ][- 1 ][0 ], userId , 0 ))
73
73
for uid in self .__followings [userId ]:
74
74
if self .__messages [uid ]:
75
- heapq .heappush (max_heap , (- self .__messages [uid ][- 1 ][0 ], uid , 0 , len ( self . __messages [ uid ]) ))
75
+ heapq .heappush (max_heap , (- self .__messages [uid ][- 1 ][0 ], uid , 0 ))
76
76
77
77
result = []
78
78
while max_heap and len (result ) < self .__number_of_most_recent_tweets :
79
- t , uid , curr , end = heapq .heappop (max_heap )
79
+ t , uid , curr = heapq .heappop (max_heap )
80
80
nxt = curr + 1 ;
81
- if nxt != end :
82
- heapq .heappush (max_heap , (- self .__messages [uid ][- (nxt + 1 )][0 ], uid , nxt , len ( self . __messages [ uid ]) ))
81
+ if nxt != len ( self . __messages [ uid ]) :
82
+ heapq .heappush (max_heap , (- self .__messages [uid ][- (nxt + 1 )][0 ], uid , nxt ))
83
83
result .append (self .__messages [uid ][- (curr + 1 )][1 ]);
84
84
return result
85
85
0 commit comments