Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 275ecc7

Browse files
Add C++ implementation
Signed-off-by: begeekmyfriend <begeekmyfriend@gmail.com>
1 parent fd94736 commit 275ecc7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎460_lfu_cache/lfu_cache.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ static void avl_tree_destory(FreqAVLTree *tree)
319319

320320
static void freq_incr(FreqAVLTree* tree, LFUNode *lfu, int key)
321321
{
322-
/* erase */
323322
list_del(&lfu->dlink);
324323
if (list_empty(&lfu->node->dhead)) {
324+
/* we must erase the empty node to rearrange the AVL tree */
325325
avl_node_erase(tree, lfu->node);
326326
}
327327

@@ -383,6 +383,7 @@ void lFUCachePut(LFUCache* obj, int key, int value)
383383
list_del(&lfu->dlink);
384384
list_del(&lfu->key_link);
385385
if (list_empty(&node->dhead)) {
386+
/* we must erase the empty node to rearrange the AVL tree */
386387
avl_node_erase(obj->tree, node);
387388
}
388389
} else {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /