<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="A priority queue implemented with a binary heap."><title>BinaryHeap in arduboy_rust::heapless - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../../static.files/rustdoc-fa3bb1812debf86c.css"><metaname="rustdoc-vars"data-root-path="../../"data-static-root-path="../../static.files/"data-current-crate="arduboy_rust"data-themes=""data-resource-suffix=""data-rustdoc-version="1.75.0-nightly (2bbb61989 2023-10-04)"data-channel="nightly"data-search-js="search-8be46b629f5f14a8.js"data-settings-js="settings-74424d7eec62a23e.js"><scriptsrc="../../static.files/storage-fec3eaa3851e447d.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../static.files/main-c5bd66d33317d69f.js"></script><noscript><linkrel="stylesheet"href="../../static.files/noscript-5d8b3c7633ad77ba.css"></noscript><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button><aclass="logo-container"href="../../arduboy_rust/index.html"><imgclass="rust-logo"src="../../static.files/rust-logo-151179464ae7ed46.svg"alt="logo"></a></nav><navclass="sidebar"><aclass="logo-container"href="../../arduboy_rust/index.html"><imgclass="rust-logo"src="../../static.files/rust-logo-151179464ae7ed46.svg"alt="logo"></a><h2class="location"><ahref="#">BinaryHeap</a></h2><divclass="sidebar-elems"><section><h3><ahref="#implementations">Methods</a></h3><ulclass="block"><li><ahref="#method.capacity">capacity</a></li><li><ahref="#method.clear">clear</a></li><li><ahref="#method.into_vec">into_vec</a></li><li><ahref="#method.is_empty">is_empty</a></li><li><ahref="#method.iter">iter</a></li><li><ahref="#method.iter_mut">iter_mut</a></li><li><ahref="#method.len">len</a></li><li><ahref="#method.new">new</a></li><li><ahref="#method.peek">peek</a></li><li><ahref="#method.peek_mut">peek_mut</a></li><li><ahref="#method.pop">pop</a></li><li><ahref="#method.pop_unchecked">pop_unchecked</a></li><li><ahref="#method.push">push</a></li><li><ahref="#method.push_unchecked">push_unchecked</a></li></ul><h3><ahref="#trait-implementations">Trait Implementations</a></h3><ulclass="block"><li><ahref="#impl-Clone-for-BinaryHeap%3CT,+K,+N%3E">Clone</a></li><li><ahref="#impl-Debug-for-BinaryHeap%3CT,+K,+N%3E">Debug</a></li><li><ahref="#impl-Default-for-BinaryHeap%3CT,+K,+N%3E">Default</a></li><li><ahref="#impl-IntoIterator-for-%26'a+BinaryHeap%3CT,+K,+N%3E">IntoIterator</a></li></ul><h3><ahref="#synthetic-implementations">Auto Trait Implementations</a></h3><ulclass="block"><li><ahref="#impl-RefUnwindSafe-for-Binar
K: <aclass="trait"href="binary_heap/trait.Kind.html"title="trait arduboy_rust::heapless::binary_heap::Kind">Kind</a>,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.capacity"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#135">source</a><h4class="code-header">pub fn <ahref="#method.capacity"class="fn">capacity</a>(&self) -> usize</h4></section></summary><divclass="docblock"><p>Returns the capacity of the binary heap.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.clear"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#154">source</a><h4class="code-header">pub fn <ahref="#method.clear"class="fn">clear</a>(&mut self)</h4></section></summary><divclass="docblock"><p>Drops all items from the binary heap.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.len"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#169">source</a><h4class="code-header">pub fn <ahref="#method.len"class="fn">len</a>(&self) -> usize</h4></section></summary><divclass="docblock"><p>Returns the length of the binary heap.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.is_empty"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#188">source</a><h4class="code-header">pub fn <ahref="#method.is_empty"class="fn">is_empty</a>(&self) -> bool</h4></section></summary><divclass="docblock"><p>Checks if the binary heap is empty.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.iter"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#209">source</a><h4class="code-header">pub fn <ahref="#method.iter"class="fn">iter</a>(&self) -> Iter<'_, T></h4></section></summary><divclass="docblock"><p>Returns an iterator visiting all values in the underlying vector, in arbitrary order.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.iter_mut"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#217">source</a><h4class="code-header">pub fn <ahref="#method.iter_mut"class="fn">iter_mut</a>(&mut self) -> IterMut<'_, T></h4></section></summary><divclass="docblock"><p>Returns a mutable iterator visiting all values in the underlying vector, in arbitrary order.</p>
<p><strong>WARNING</strong> Mutating the items in the binary heap can leave the heap in an inconsistent
state.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.peek"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#235">source</a><h4class="code-header">pub fn <ahref="#method.peek"class="fn">peek</a>(&self) -> Option<&T></h4></section></summary><divclass="docblock"><p>Returns the <em>top</em> (greatest if max-heap, smallest if min-heap) item in the binary heap, or
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.peek_mut"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#265">source</a><h4class="code-header">pub fn <ahref="#method.peek_mut"class="fn">peek_mut</a>(&mut self) -> Option<<aclass="struct"href="binary_heap/struct.PeekMut.html"title="struct arduboy_rust::heapless::binary_heap::PeekMut">PeekMut</a><'_, T, K, N>></h4></section></summary><divclass="docblock"><p>Returns a mutable reference to the greatest item in the binary heap, or
<code>None</code> if it is empty.</p>
<p>Note: If the <code>PeekMut</code> value is leaked, the heap may be in an
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.pop"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#290">source</a><h4class="code-header">pub fn <ahref="#method.pop"class="fn">pop</a>(&mut self) -> Option<T></h4></section></summary><divclass="docblock"><p>Removes the <em>top</em> (greatest if max-heap, smallest if min-heap) item from the binary heap and
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.pop_unchecked"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#300">source</a><h4class="code-header">pub unsafe fn <ahref="#method.pop_unchecked"class="fn">pop_unchecked</a>(&mut self) -> T</h4></section></summary><divclass="docblock"><p>Removes the <em>top</em> (greatest if max-heap, smallest if min-heap) item from the binary heap and
returns it, without checking if the binary heap is empty.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.push"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#323">source</a><h4class="code-header">pub fn <ahref="#method.push"class="fn">push</a>(&mut self, item: T) -> Result<(), T></h4></section></summary><divclass="docblock"><p>Pushes an item onto the binary heap.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.push_unchecked"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#333">source</a><h4class="code-header">pub unsafe fn <ahref="#method.push_unchecked"class="fn">push_unchecked</a>(&mut self, item: T)</h4></section></summary><divclass="docblock"><p>Pushes an item onto the binary heap without first checking if it’s full.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.into_vec"class="method"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#340">source</a><h4class="code-header">pub fn <ahref="#method.into_vec"class="fn">into_vec</a>(self) -><aclass="struct"href="struct.Vec.html"title="struct arduboy_rust::heapless::Vec">Vec</a><T, N></h4></section></summary><divclass="docblock"><p>Returns the underlying <code>Vec<T,N></code>. Order is arbitrary and time is O(1).</p>
T: Ord + Debug,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.fmt"class="method trait-impl"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#550">source</a><ahref="#method.fmt"class="anchor">§</a><h4class="code-header">fn <aclass="fn">fmt</a>(&self, f: &mut Formatter<'_>) -> Result<(), Error></h4></section></summary><divclass='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-Default-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#522">source</a><ahref="#impl-Default-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T, K, const N: usize> Default for <aclass="struct"href="struct.BinaryHeap.html"title="struct arduboy_rust::heapless::BinaryHeap">BinaryHeap</a><T, K, N><spanclass="where fmt-newline">where
T: Ord,
K: <aclass="trait"href="binary_heap/trait.Kind.html"title="trait arduboy_rust::heapless::binary_heap::Kind">Kind</a>,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.default"class="method trait-impl"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#527">source</a><ahref="#method.default"class="anchor">§</a><h4class="code-header">fn <aclass="fn">default</a>() -><aclass="struct"href="struct.BinaryHeap.html"title="struct arduboy_rust::heapless::BinaryHeap">BinaryHeap</a><T, K, N></h4></section></summary><divclass='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"open><summary><sectionid="impl-IntoIterator-for-%26'a+BinaryHeap%3CT,+K,+N%3E"class="impl"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#555">source</a><ahref="#impl-IntoIterator-for-%26'a+BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<'a, T, K, const N: usize> IntoIterator for &'a <aclass="struct"href="struct.BinaryHeap.html"title="struct arduboy_rust::heapless::BinaryHeap">BinaryHeap</a><T, K, N><spanclass="where fmt-newline">where
T: Ord,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Item"class="associatedtype trait-impl"><ahref="#associatedtype.Item"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Item</a> = &'a T</h4></section></summary><divclass='docblock'>The type of the elements being iterated over.</div></details><detailsclass="toggle"open><summary><sectionid="associatedtype.IntoIter"class="associatedtype trait-impl"><ahref="#associatedtype.IntoIter"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">IntoIter</a> = Iter<'a, T></h4></section></summary><divclass='docblock'>Which kind of iterator are we turning this into?</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.into_iter"class="method trait-impl"><aclass="src rightside"href="../../src/heapless/binary_heap.rs.html#563">source</a><ahref="#method.into_iter"class="anchor">§</a><h4class="code-header">fn <aclass="fn">into_iter</a>(self) -><&'a <aclass="struct"href="struct.BinaryHeap.html"title="struct arduboy_rust::heapless::BinaryHeap">BinaryHeap</a><T, K, N> as IntoIterator>::IntoIter</h4></section></summary><divclass='docblock'>Creates an iterator from a value. <a>Read more</a></div></details></div></details></div><h2id="synthetic-implementations"class="small-section-header">Auto Trait Implementations<ahref="#synthetic-implementations"class="anchor">§</a></h2><divid="synthetic-implementations-list"><sectionid="impl-RefUnwindSafe-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-RefUnwindSafe-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T, K, const N: usize> RefUnwindSafe for <aclass="struct"href="struct.BinaryHeap.html"title="struct arduboy_rust::heapless::BinaryHeap">BinaryHeap</a><T, K, N><spanclass="where fmt-newline">where
T: UnwindSafe,</span></h3></section></div><h2id="blanket-implementations"class="small-section-header">Blanket Implementations<ahref="#blanket-implementations"class="anchor">§</a></h2><divid="blanket-implementations-list"><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Any-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-Any-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T> Any for T<spanclass="where fmt-newline">where
T: 'static + ?Sized,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.type_id"class="method trait-impl"><ahref="#method.type_id"class="anchor">§</a><h4class="code-header">fn <aclass="fn">type_id</a>(&self) -> TypeId</h4></section></summary><divclass='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Borrow%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-Borrow%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T> Borrow<T> for T<spanclass="where fmt-newline">where
T: ?Sized,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.borrow"class="method trait-impl"><ahref="#method.borrow"class="anchor">§</a><h4class="code-header">fn <aclass="fn">borrow</a>(&self) ->&T</h4></section></summary><divclass='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-BorrowMut%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-BorrowMut%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T> BorrowMut<T> for T<spanclass="where fmt-newline">where
T: ?Sized,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.borrow_mut"class="method trait-impl"><ahref="#method.borrow_mut"class="anchor">§</a><h4class="code-header">fn <aclass="fn">borrow_mut</a>(&mut self) ->&mut T</h4></section></summary><divclass='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-From%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-From%3CT%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T> From<T> for T</h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.from"class="method trait-impl"><ahref="#method.from"class="anchor">§</a><h4class="code-header">fn <aclass="fn">from</a>(t: T) -> T</h4></section></summary><divclass="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Into%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-Into%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T, U> Into<U> for T<spanclass="where fmt-newline">where
<p>That is, this conversion is whatever the implementation of
<code>[From]<T> for U</code> chooses to do.</p>
</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryFrom%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-TryFrom%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T, U> TryFrom<U> for T<spanclass="where fmt-newline">where
U: Into<T>,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error-1"class="associatedtype trait-impl"><ahref="#associatedtype.Error-1"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Error</a> = Infallible</h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_from"class="method trait-impl"><ahref="#method.try_from"class="anchor">§</a><h4class="code-header">fn <aclass="fn">try_from</a>(value: U) -> Result<T, <T as TryFrom<U>>::Error></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-TryInto%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="impl"><ahref="#impl-TryInto%3CU%3E-for-BinaryHeap%3CT,+K,+N%3E"class="anchor">§</a><h3class="code-header">impl<T, U> TryInto<U> for T<spanclass="where fmt-newline">where
U: TryFrom<T>,</span></h3></section></summary><divclass="impl-items"><detailsclass="toggle"open><summary><sectionid="associatedtype.Error"class="associatedtype trait-impl"><ahref="#associatedtype.Error"class="anchor">§</a><h4class="code-header">type <aclass="associatedtype">Error</a> = <U as TryFrom<T>>::Error</h4></section></summary><divclass='docblock'>The type returned in the event of a conversion error.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.try_into"class="method trait-impl"><ahref="#method.try_into"class="anchor">§</a><h4class="code-header">fn <aclass="fn">try_into</a>(self) -> Result<U, <U as TryFrom<T>>::Error></h4></section></summary><divclass='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>