summaryrefslogtreecommitdiffstats
path: root/src/metric/forest.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/metric/forest.rs')
-rw-r--r--src/metric/forest.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/metric/forest.rs b/src/metric/forest.rs
index 47eb413..887ff12 100644
--- a/src/metric/forest.rs
+++ b/src/metric/forest.rs
@@ -50,6 +50,24 @@ where
}
len
}
+
+ /// Check if this forest is empty.
+ pub fn is_empty(&self) -> bool {
+ if !self.buffer.is_empty() {
+ return false;
+ }
+
+ self.trees.iter().flatten().next().is_none()
+ }
+}
+
+impl<T, U> Default for Forest<U>
+where
+ U: FromIterator<T> + IntoIterator<Item = T>,
+{
+ fn default() -> Self {
+ Self::new()
+ }
}
impl<T, U> Extend<T> for Forest<U>