Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Core::FIFOCache #79

Merged
merged 6 commits into from
Jan 10, 2025
Merged

Add Core::FIFOCache #79

merged 6 commits into from
Jan 10, 2025

Conversation

SimBe195
Copy link
Collaborator

Cache based on an unordered_map with a maximum size such that when the cache is full and
a new item is trying to be added, the oldest item in the cache gets removed.
Note: oldest is determined by order of insertion, not order of last access.

Example:

FIFOCache<int, std::string> cache(2);  // Cache has room for two items
cache.put(1, "one");  // Internal data: {1: "one"}
cache.put(2, "two");  // Internal data: {1: "one", 2: "two"}
cache.put(3, "three");  // Oldest element is deleted since max size was reached. Internal data: {2: "two", 3: "three"}

src/Core/FIFOCache.hh Outdated Show resolved Hide resolved
src/Core/FIFOCache.hh Outdated Show resolved Hide resolved
@curufinwe
Copy link
Contributor

PS: same comment about adding inline as in #78

@SimBe195 SimBe195 requested a review from curufinwe December 5, 2024 10:17
src/Core/FIFOCache.hh Outdated Show resolved Hide resolved
@SimBe195 SimBe195 requested a review from curufinwe January 10, 2025 09:57
@curufinwe curufinwe merged commit eb5c0ae into master Jan 10, 2025
@curufinwe curufinwe deleted the fifo-cache branch January 10, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants