diff --git a/src/data_structures/min_heap.rs b/src/data_structures/min_heap.rs index 2996a82..9dfe509 100644 --- a/src/data_structures/min_heap.rs +++ b/src/data_structures/min_heap.rs @@ -26,3 +26,25 @@ impl Default for MinHeap { Self::new() } } + +impl From<[T; N]> for MinHeap +where + T: Ord, +{ + fn from(value: [T; N]) -> Self { + Self { + heap: BinaryHeap::from(value.map(|x| Reverse(x))), + } + } +} + +impl FromIterator for MinHeap +where + T: Ord, +{ + fn from_iter>(iter: U) -> Self { + Self { + heap: BinaryHeap::from_iter(iter.into_iter().map(|x| Reverse(x))), + } + } +}