Giter Club home page Giter Club logo

cpp-lru-cache's Introduction

cpp-lru-cache

Simple and reliable LRU (Least Recently Used) cache for c++ based on hashmap and linkedlist. The library is header only, simple test and example are included. It includes standard components and very little own logics that guarantees reliability.

How to run tests(need clone googletest)

mkdir build
cd build
cmake ..
make check

Full Example(原有代码使用例子):

#include "lrucache.hpp"
#include <iostream>

int main()
{
    /**Creates cache with maximum size of three. When the 
    size in achieved every next element will replace the 
    least recently used one */
    
    cache::lru_cache<int, std::string> cache(3);

    cache.put(0, "zero");
    cache.put(1, "two");
    cache.put(2, "three");
    cache.put(3, "four");
    cache.put(4, "five");

    const std::string &from_cache = cache.get(4);
    std::cout << from_cache << std::endl;

    return 0;
}

中文版本:

学习lamerman/cpp-lru-cache的lru的实现,记录学习中遇到的疑问。

####namespace

C++命名空间

维基百科-名字空间

####typename

typename

知无涯之C++ typename的起源与用法

源代码修改注释版本:

include/lrucache.hpp

修改部分实现方式 添加注释 修改函数接口 简单单测

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.