Comments (2)
Hello @sg-james,
Thank you for the report and a PR! I will take a look at your changes.
from caches.
I managed to create a simple test case that catches the bug
TEST(FIFOCache, Remove_Test_FifoRemoveBug_issue21) {
constexpr std::size_t TEST_SIZE = 3;
fifo_cache_t <std::string, std::size_t> fc(TEST_SIZE);
for (std::size_t i = 0; i < TEST_SIZE; ++i) {
fc.Put(std::to_string(i), i);
}
// CachePolicy { 2, 1, 0 } CacheMap { 0, 1, 2 }
const int specific_key = 1;
EXPECT_TRUE(fc.Remove(std::to_string(specific_key))); // CachePolicy { 2, 1 } -> 0 CacheMap { 0, 2 }
fc.Put(std::to_string(3), 3); // CachePolicy { 3, 2, 1 } CacheMap { 0, 2, 3 }
fc.Put(std::to_string(4), 4); // { 4, 3, 2 } -> 1 CacheMap.erase("1") // error
EXPECT_EQ(fc.Size(), TEST_SIZE);
}
My PRs approach trades complexity for memory, but perhaps an O(n)
removal lookup would be preferable to a second data structure?
from caches.
Related Issues (15)
- operation_guard not locking HOT 3
- Update Get method to return std::optional HOT 2
- using as cmake HOT 1
- small edit in the readme example HOT 1
- Uncomplicated multithreaded design? HOT 2
- multithreading issue HOT 3
- Pass map as template param to replace unorder_map HOT 4
- cache_policy.hpp raises warning when compiled with -Wunused-parameter HOT 1
- It works for iOS and Android? HOT 2
- 是否支持时间过期? HOT 2
- 你好,请问是线程安全的吗
- `std::unordered_set` does not have a function named `crbegin` HOT 2
- overload the Get function when the key is not in the cache HOT 2
- change the permission for Erase() to public HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caches.