aboutsummaryrefslogtreecommitdiff
path: root/src/mruset.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mruset.h')
-rw-r--r--src/mruset.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mruset.h b/src/mruset.h
index b9f325d874..1691875f57 100644
--- a/src/mruset.h
+++ b/src/mruset.h
@@ -10,7 +10,8 @@
#include <utility>
/** STL-like set container that only keeps the most recent N elements. */
-template <typename T> class mruset
+template <typename T>
+class mruset
{
public:
typedef T key_type;
@@ -32,17 +33,19 @@ public:
bool empty() const { return set.empty(); }
iterator find(const key_type& k) const { return set.find(k); }
size_type count(const key_type& k) const { return set.count(k); }
- void clear() { set.clear(); queue.clear(); }
+ void clear()
+ {
+ set.clear();
+ queue.clear();
+ }
bool inline friend operator==(const mruset<T>& a, const mruset<T>& b) { return a.set == b.set; }
bool inline friend operator==(const mruset<T>& a, const std::set<T>& b) { return a.set == b; }
bool inline friend operator<(const mruset<T>& a, const mruset<T>& b) { return a.set < b.set; }
std::pair<iterator, bool> insert(const key_type& x)
{
std::pair<iterator, bool> ret = set.insert(x);
- if (ret.second)
- {
- if (nMaxSize && queue.size() == nMaxSize)
- {
+ if (ret.second) {
+ if (nMaxSize && queue.size() == nMaxSize) {
set.erase(queue.front());
queue.pop_front();
}
@@ -54,8 +57,7 @@ public:
size_type max_size(size_type s)
{
if (s)
- while (queue.size() > s)
- {
+ while (queue.size() > s) {
set.erase(queue.front());
queue.pop_front();
}