This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
public class LRUCache<T> { | |
private final int capacity; | |
private int size; | |
private final Map<String, Node> hashMap; | |
private final DoublyLinkedList internalQueue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.WeakHashMap; | |
import java.util.concurrent.ConcurrentHashMap; | |
/** | |
* ConcurrentCache | |
* Tomcat 中的 ConcurrentCache 使用了 WeakHashMap 来实现缓存功能。 | |
* <p> | |
* ConcurrentCache 采取的是分代缓存: | |
* <p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wuxianggujun.toolbox; | |
import java.io.*; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
public class FileSystemClassLoader extends ClassLoader { | |
private final String rootDir; | |
public FileSystemClassLoader(String rootDir) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Iterator; | |
/** | |
* 以下是基于 双向链表 + HashMap 的 LRU 算法实现,对算法的解释如下: | |
* | |
* 访问某个节点时,将其从原来的位置删除,并重新插入到链表头部。这样就能保证链表尾部存储的就是最近最久未使用的节点,当节点数量大于缓存最大空间时就淘汰链表尾部的节点。 | |
* 为了使删除操作时间复杂度为 O(1),就不能采用遍历的方式找到某个节点。HashMap 存储着 Key 到节点的映射,通过 Key 就能以 O(1) 的时间得到节点,然后再以 O(1) 的时间将其从双向队列中删除。 | |
* @param <K> | |
* @param <V> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ParsingCsvDemo.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// | |
#include <iostream> | |
#include <string> | |
#include <fstream> | |
#include <sstream> | |
#include <vector> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by WuXiangGuJun on 2023/6/18. | |
// | |
#pragma once | |
#include <iostream> | |
#include <QTime> | |
#include <QTimer> | |
#include <QOpenGLWidget> | |
#include <QOpenGLFunctions> |