MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / next_back

Method next_back

cranelift/bforest/src/map.rs:779–821  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

777 C: Comparator<K>,
778{
779 fn next_back(&mut self) -> Option<Self::Item> {
780 let old_direction = mem::replace(&mut self.direction, Direction::NextBack);
781
782 let key_val = (|| {
783 if old_direction == Direction::NextBack {
784 self.cursor.prev()
785 } else {
786 match self.end {
787 Bound::Included(k) => match self.cursor.goto(k) {
788 Some(_) => Some((self.cursor.key()?, self.cursor.value()?)),
789 None => self.cursor.prev(),
790 },
791 Bound::Excluded(k) => {
792 self.cursor.goto(k);
793 if self
794 .cursor
795 .key()
796 .is_some_and(|key| self.cursor.comp.cmp(k, key).is_eq())
797 {
798 self.cursor.prev()
799 } else {
800 Some((self.cursor.key()?, self.cursor.value()?))
801 }
802 }
803 Bound::Unbounded => {
804 self.cursor.goto_end();
805 self.cursor.prev()
806 }
807 }
808 }
809 })();
810
811 match key_val {
812 Some((key, val)) if self.is_in_bounds(key) => {
813 self.end = Bound::Excluded(key);
814 Some((key, val))
815 }
816 _ => {
817 self.cursor.goto_end();
818 None
819 }
820 }
821 }
822}
823
824impl<'a, K, V, C> MapRange<'a, K, V, C>

Callers

nothing calls this directly

Calls 9

is_eqMethod · 0.80
goto_endMethod · 0.80
is_in_boundsMethod · 0.80
replaceFunction · 0.50
prevMethod · 0.45
gotoMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected