Swift 的 LRU 缓存 SwiftlyLRU

码农软件 · 软件分类 · 其他(Others) · 2019-07-17 15:41:43

软件介绍

SwiftlyLRU 是一款使用的纯 Swift实现的  LRU 缓存。近期,老项目已不被使用,已在缓存中丢弃了它。SwiftlyLRU  是理想化了的模型,它提供了大型列表和无限滚动。其时间和空间复杂度是 O(1) ,由于采用了泛型,所以它可以存储任何数值。你需要将 SwiftlyLRU.swift  拉到你的工程中就可以运行了。

//// Example//import Foundation//...//Create cache with capacityvar cache = SwiftlyLRU<String, Float>(capacity: 7)    //Add Key, Value pairs
    cache["AAPL"] = 114.63
    cache["GOOG"] = 533.75
    cache["YHOO"] = 50.67
    cache["TWTR"] = 38.91
    cache["BABA"] = 109.89
    cache["YELP"] = 55.17
    cache["BABA"] = 109.80
    cache["TSLA"] = 231.43
    cache["AAPL"] = 113.41
    cache["GOOG"] = 533.60
    cache["AAPL"] = 113.01

    //Retrieve
    if let item = cache["AAPL"] {
        println("Key: AAPL Value: \(item)")
    } else {
        println("Item not found.")
    }/* OUTPUT        Key: AAPL Value: 113.01*/

    //Describe
    println(cache)/* OUTPUT    SwiftlyLRU Cache(7)     Key: AAPL Value: Optional(113.01)     Key: GOOG Value: Optional(533.6)     Key: TSLA Value: Optional(231.43)     Key: BABA Value: Optional(109.8)     Key: YELP Value: Optional(55.17)     Key: TWTR Value: Optional(38.91)     Key: YHOO Value: Optional(50.67) *///...


本文地址:https://codercto.com/soft/d/10339.html

C++ Concurrency in Action

C++ Concurrency in Action

Anthony Williams / Manning Publications / 2012-2-28 / USD 69.99

HIGHLIGHT C++ Concurrency in Action is the first book to market to show how to take advantage of the new C++ Standard and how to write robust multi-threaded applications in C++. DESCRIPTION With ......一起来看看 《C++ Concurrency in Action》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具