Skip to content

Commit 6d8612c

Browse files
committed
feat: add Graph::len() and Graph::is_empty()
Get an idea about he size of the graph.
1 parent 60f0e00 commit 6d8612c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gix-revwalk/src/graph/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ impl<'find, 'cache, T: Default> Graph<'find, 'cache, T> {
7575

7676
/// Access and mutation
7777
impl<'find, 'cache, T> Graph<'find, 'cache, T> {
78+
/// Returns the amount of entries in the graph.
79+
pub fn len(&self) -> usize {
80+
self.map.len()
81+
}
82+
83+
/// Returns `true` if there is no entry in the graph.
84+
pub fn is_empty(&self) -> bool {
85+
self.map.is_empty()
86+
}
87+
7888
/// Returns true if `id` has data associated with it, meaning that we processed it already.
7989
pub fn contains(&self, id: &gix_hash::oid) -> bool {
8090
self.map.contains_key(id.as_ref())

0 commit comments

Comments
 (0)