diff options
Diffstat (limited to 'libtransport/src/utils/min_filter.h')
-rw-r--r-- | libtransport/src/utils/min_filter.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libtransport/src/utils/min_filter.h b/libtransport/src/utils/min_filter.h index dcfd5652d..4a3882601 100644 --- a/libtransport/src/utils/min_filter.h +++ b/libtransport/src/utils/min_filter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -15,9 +15,6 @@ #pragma once -#include <hicn/transport/portability/portability.h> -#include <hicn/transport/utils/log.h> - #include <deque> #include <iostream> #include <set> @@ -31,10 +28,10 @@ class MinFilter { public: MinFilter(std::size_t size) : size_(size) {} - std::size_t size() { return by_arrival_.size(); } + std::size_t size() const { return by_arrival_.size(); } template <typename R> - TRANSPORT_ALWAYS_INLINE void pushBack(R&& value) { + void pushBack(R&& value) { if (by_arrival_.size() >= size_) { by_order_.erase(by_arrival_.back()); by_arrival_.pop_back(); @@ -43,9 +40,14 @@ class MinFilter { by_arrival_.push_front(by_order_.insert(std::forward<R>(value))); } - TRANSPORT_ALWAYS_INLINE const T& begin() { return *by_order_.cbegin(); } + void clear() { + by_arrival_.clear(); + by_order_.clear(); + } + + const T& begin() const { return *by_order_.cbegin(); } - TRANSPORT_ALWAYS_INLINE const T& rBegin() { return *by_order_.crbegin(); } + const T& rBegin() const { return *by_order_.crbegin(); } private: std::multiset<T> by_order_; |