GithubHelp home page GithubHelp logo

lru-cache-cpp's People

Contributors

pbrunelle avatar

Watchers

 avatar

lru-cache-cpp's Issues

cache empty returns inverse

What is the expected output?
   Expected empty() to return true if the cache was empty (as do stl collections).

What do you see instead?
   Returns the inverse ( return size() > 0; )

What version of the product are you using? On what operating system?
   No version in source. Latest

Original issue reported on code.google.com by [email protected] on 16 Apr 2012 at 8:02

1) using std::string as a key. 2) contact email is not responding

What steps will reproduce the problem?
1. use <std::string> as a Key type and <MyClass> as a Value type
<int> for MyClass will work here.

2. To make hash_map work with std::string I followed the tips from 
 http://the-lost-beauty.blogspot.com/2008/10/cc-gnucxx-hashmap-under-ubuntu-804.html and http://forums.devshed.com/c-programming-42/tip-about-stl-hash-map-and-string-55093.html

3. Declare LRUCache<std::string, MyClass> with 100 max_size elements.
I call LRUCache insert() method  few hundreds  of times.
Then cache is full the _erase() method is called - hence the key and value 
should be available at this moment. 
But I think what currently LRUCache does not keep std::string internally - it 
just keeps string.c_str() which is not enough, because the original string from 
main apps may be already destroyed.
And of course we do not want to keep in main application the millions of 
std::string and MyClass objects for the application lifetime - it should be 
business of LRUCache to keep the keys (not just the pointers to keys).

Currently I have the memory corruption in _erase() - it is reported by 
valgrind. 
Thanks for quick reply!
[email protected]

Original issue reported on code.google.com by [email protected] on 26 Sep 2011 at 11:27

Patch for /lru.hpp

 *  1. Change hashtable to hash_map as the container
 *  2. Add memory limit 
 *  3. Add value deletor(optional)
 *  4. Change LRUCacheH4Value::Val : use a pointer to optimize the memory use
 *  5. MS-VC compile pass 

Original issue reported on code.google.com by [email protected] on 11 Jul 2012 at 1:56

Attachments:

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.