Coder Social home page Coder Social logo

justinmfischer / swiftlylru Goto Github PK

View Code? Open in Web Editor NEW
57.0 57.0 12.0 28 KB

SwiftlyLRU is a pure Swift Least Recently Used "LRU" Cache. Older items that have not been recently used are discarded from the cache. This is the ideal pattern for large lists and infinite scrolling. The time, space complexity is O(1) and thanks to generics any values can be stored. Simply drag SwiftlyLRU.swift into your project to get started!

License: MIT License

Swift 100.00%

swiftlylru's People

Contributors

afshin-hoseini avatar justinmfischer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

swiftlylru's Issues

Memory leaks

Couple of errors in your code that result in reference cycles.

  1. Node. previous should be a weak link
  2. Remove method doesn't set node's next and previous link to nil
  3. SwiftlyLRU subscript setter should use self.queue.remove(self.queue.tail!) to drop the node

cheers
CR

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.