Add an out_degree method for nodes.

This commit is contained in:
Jeremy Wall 2022-09-05 08:56:01 -04:00
parent 4f3f554285
commit 2683a7baab
2 changed files with 8 additions and 2 deletions

View File

@ -120,4 +120,8 @@ where
pub fn dependency_ids(&self) -> &BTreeSet<Vec<u8>> {
&self.dependency_ids
}
pub fn out_degree(&self) -> usize {
self.dependency_ids.len()
}
}

View File

@ -13,7 +13,7 @@
// limitations under the License.
//! The MerkleDag backing store trait.
use std::collections::BTreeMap;
use std::{collections::BTreeMap, hash::Hash};
use crate::{hash::HashWriter, node::Node};
@ -38,7 +38,9 @@ where
fn store(&mut self, node: Node<HW>) -> Result<()>;
}
impl<HW> Store<HW> for BTreeMap<Vec<u8>, Node<HW>>
pub type BTreeStore<HW> = BTreeMap<Vec<u8>, Node<HW>>;
impl<HW> Store<HW> for BTreeStore<HW>
where
HW: HashWriter,
{