pub trait BitScan {
// Required methods
fn index_of_next_false_bit(self, start: u64) -> Option<u64>;
fn index_of_next_true_bit(self, start: u64) -> Option<u64>;
}
Expand description
Defines functions that search for the next true
or false
bit in a number, starting at a
specified index and searching in the more-significant direction.
Required Methods§
sourcefn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a false
bit that is greater than or equal to the starting index.
sourcefn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a true
bit that is greater than or equal to the starting index.
Implementations on Foreign Types§
source§impl BitScan for i8
impl BitScan for i8
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for i16
impl BitScan for i16
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for i32
impl BitScan for i32
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for i64
impl BitScan for i64
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for i128
impl BitScan for i128
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for isize
impl BitScan for isize
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is negative. If it is, then the result is None
since
there are no false
bits past that point. If the number is non-negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, then the result
depends on whether the number is non-negative. If it is, then the result is None
since there are no true
bits past that point. If the number is negative, then the
result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for u8
impl BitScan for u8
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for u16
impl BitScan for u16
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for u32
impl BitScan for u32
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for u64
impl BitScan for u64
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for u128
impl BitScan for u128
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§impl BitScan for usize
impl BitScan for usize
source§fn index_of_next_false_bit(self, start: u64) -> Option<u64>
fn index_of_next_false_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
false
bit that is greater than or equal to the starting index.
Since the number is unsigned and therefore has an implicit prefix of infinitely-many zeros, this function always returns a value.
Starting beyond the type’s width is allowed; the result is the starting index.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
source§fn index_of_next_true_bit(self, start: u64) -> Option<u64>
fn index_of_next_true_bit(self, start: u64) -> Option<u64>
Given a number and a starting index, searches the number for the smallest index of a
true
bit that is greater than or equal to the starting index.
If the starting index is greater than or equal to the type’s width, the result is
None
since there are no true
bits past that point.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.