diff --git a/src/lib.rs b/src/lib.rs index 2950855..b1acf60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -250,16 +250,18 @@ impl ExpiringMap { self.inner.reserve(addtional); } - /// Shrink the internal map to the minimum allowable size - /// in accordance with the resize policy + /// Remove all of the expired entries and shrink the map to the minimum + /// allowable size in accordance with the resize policy pub fn shrink_to_fit(&mut self) { + self.vacuum(); self.inner.shrink_to_fit(); } - /// Shrink the internal map to the minimum of the - /// minimum allowable size and the `min_capacity` - /// in accordance with the resize policy + /// Remove all of the expired entries and shrink the map to the minimum of + /// the minimum allowable size and the `min_capacity` in accordance with the + /// resize policy pub fn shrink_to(&mut self, min_capacity: usize) { + self.vacuum(); self.inner.shrink_to(min_capacity); } } @@ -311,6 +313,18 @@ impl ExpiringSet { .filter(|(_, v)| v.not_expired()) .map(|v| v.0) } + + /// Shrink the set to the minimum allowable size in accordance with the + /// resize policy + pub fn shrink_to_fit(&mut self) { + self.0.shrink_to_fit(); + } + + /// Shrink the set to the minimum of the minimum allowable size and the + /// `min_capacity` in accordance with the resize policy + pub fn shrink_to(&mut self, min_capacity: usize) { + self.0.shrink_to(min_capacity); + } } impl Default for ExpiringMap {