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

APIs

APIs

Daniel Jacobson、Greg Brail、Dan Woods / O'Reilly Media / 2011-12-24 / USD 24.99

Many of the highest traffic sites get more than half of their traffic not through the browser but through the APIs they have created. Salesforce.com (more than 50%) and Twitter (more than 75% fall int......一起来看看 《APIs》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

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

HSV CMYK互换工具