MCPcopy Create free account
hub / github.com/apache/arrow-rs / nth

Method nth

arrow-buffer/src/util/bit_iterator.rs:85–104  ·  view source on GitHub ↗
(&mut self, n: usize)

Source from the content-addressed store, hash-verified

83
84 #[inline]
85 fn nth(&mut self, n: usize) -> Option<Self::Item> {
86 // Check if we can advance to the desired offset.
87 // When n is 0 it means we want the next() value
88 // and when n is 1 we want the next().next() value
89 // so adding n to the current offset and not n - 1
90 match self.current_offset.checked_add(n) {
91 // Yes, and still within bounds
92 Some(new_offset) if new_offset < self.end_offset => {
93 self.current_offset = new_offset;
94 }
95
96 // Either overflow or would exceed end_offset
97 _ => {
98 self.current_offset = self.end_offset;
99 return None;
100 }
101 }
102
103 self.next()
104 }
105
106 fn last(mut self) -> Option<Self::Item> {
107 // If already at the end, return None

Callers 3

get_valueMethod · 0.45

Calls 2

checked_addMethod · 0.45
nextMethod · 0.45

Tested by 1