pub struct U32Set {
pages: Vec<BitPage>,
page_map: Vec<PageInfo>,
length: u64,
last_page_map_index: AtomicUsize,
}
Expand description
A fast, efficient, sparse, & ordered u32
set.
For a higher-level API that supports inversion and generic int types, use super::IntSet
Fields§
§pages: Vec<BitPage>
§page_map: Vec<PageInfo>
§length: u64
§last_page_map_index: AtomicUsize
Implementations§
Source§impl U32Set
impl U32Set
Sourcepub fn insert(&mut self, val: u32) -> bool
pub fn insert(&mut self, val: u32) -> bool
Add val as a member of this set.
If the set did not previously contain this value, returns true
.
Sourcepub fn insert_range(&mut self, range: RangeInclusive<u32>)
pub fn insert_range(&mut self, range: RangeInclusive<u32>)
Add all values in range as members of this set.
Sourcepub fn extend_unsorted<U: IntoIterator<Item = u32>>(&mut self, iter: U)
pub fn extend_unsorted<U: IntoIterator<Item = u32>>(&mut self, iter: U)
An alternate version of extend()
which is optimized for inserting an unsorted
iterator of values.
Sourcepub fn remove(&mut self, val: u32) -> bool
pub fn remove(&mut self, val: u32) -> bool
Remove val from this set.
Returns true
if the value was present.
pub fn remove_all<U: IntoIterator<Item = u32>>(&mut self, iter: U)
Sourcepub fn remove_range(&mut self, range: RangeInclusive<u32>)
pub fn remove_range(&mut self, range: RangeInclusive<u32>)
Removes all values in range as members of this set.
pub const fn empty() -> U32Set
fn recompute_length(&mut self)
pub(crate) fn num_pages(&self) -> usize
Sourcepub fn union(&mut self, other: &U32Set)
pub fn union(&mut self, other: &U32Set)
Sets the members of this set to the union of self and other.
Sourcepub fn intersect(&mut self, other: &U32Set)
pub fn intersect(&mut self, other: &U32Set)
Sets the members of this set to the intersection of self and other.
Sourcepub fn reversed_subtract(&mut self, other: &U32Set)
pub fn reversed_subtract(&mut self, other: &U32Set)
Sets the members of this set to other - self.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = u32> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = u32> + '_
Iterator over the members of this set. In sorted order (ascending).
Sourcepub fn iter_from(&self, value: u32) -> impl Iterator<Item = u32> + '_
pub fn iter_from(&self, value: u32) -> impl Iterator<Item = u32> + '_
Iterator over the members of this set starting from value.
So value is included in the iterator if it’s in the set.
Sourcepub fn iter_ranges(&self) -> impl Iterator<Item = RangeInclusive<u32>> + '_
pub fn iter_ranges(&self) -> impl Iterator<Item = RangeInclusive<u32>> + '_
Iterate over the ranges of contiguous values in this set.
fn iter_pages(&self) -> impl DoubleEndedIterator<Item = (u32, &BitPage)> + '_
fn iter_non_empty_pages( &self, ) -> impl DoubleEndedIterator<Item = (u32, &BitPage)> + '_
Sourcefn passthrough_behavior<Op>(op: &Op) -> (bool, bool)
fn passthrough_behavior<Op>(op: &Op) -> (bool, bool)
Determine the passthrough behaviour of the operator.
The passthrough behaviour is what happens to a page on one side of the operation if the other side is 0. For example union passes through both left and right sides since it preserves the left or right side when the other side is 0. Knowing this lets us optimize some cases when only one page is present on one side.
fn process<Op>(&mut self, op: Op, other: &U32Set)
fn compact(&mut self, new_len: usize)
fn compact_pages(&mut self, old_index_to_page_map_index: Vec<usize>)
fn resize(&mut self, new_len: usize)
Sourceconst fn get_major_value(value: u32) -> u32
const fn get_major_value(value: u32) -> u32
Return the major value (top 23 bits) of the page associated with value.
const fn major_start(major: u32) -> u32
const fn major_end(major: u32) -> u32
Sourcefn page_index_for_major(&self, major_value: u32) -> Option<usize>
fn page_index_for_major(&self, major_value: u32) -> Option<usize>
Returns the index in self.pages
(if it exists) for the page with the same major as major_value
.
fn page_map_index_for_major(&self, major_value: u32) -> Option<usize>
Sourcefn ensure_page_index_for_major(&mut self, major_value: u32) -> usize
fn ensure_page_index_for_major(&mut self, major_value: u32) -> usize
Returns the index in self.pages
for the page with the same major as major_value
. Will create
the page if it does not yet exist.
Sourcefn page_for_mut(&mut self, value: u32) -> Option<&mut BitPage>
fn page_for_mut(&mut self, value: u32) -> Option<&mut BitPage>
Return a mutable reference to the page that value
resides in.
Insert a new page if it doesn’t exist.
Sourcefn page_for_major_mut(&mut self, major_value: u32) -> Option<&mut BitPage>
fn page_for_major_mut(&mut self, major_value: u32) -> Option<&mut BitPage>
Return a mutable reference to the page with major value equal to major_value
.
Sourcefn ensure_page_for_mut(&mut self, value: u32) -> &mut BitPage
fn ensure_page_for_mut(&mut self, value: u32) -> &mut BitPage
Return a mutable reference to the page that value
resides in.
Insert a new page if it doesn’t exist.
Sourcefn ensure_page_for_major_mut(&mut self, major_value: u32) -> &mut BitPage
fn ensure_page_for_major_mut(&mut self, major_value: u32) -> &mut BitPage
Return a mutable reference to the page with major value equal to major_value
.
Inserts a new page if it doesn’t exist.
Sourcefn page_for_index_mut(&mut self, index: usize) -> Option<&mut BitPage>
fn page_for_index_mut(&mut self, index: usize) -> Option<&mut BitPage>
Return the mutable page at a given index
fn page_for_index(&self, index: usize) -> Option<&BitPage>
Trait Implementations§
Source§impl Extend<u32> for U32Set
impl Extend<u32> for U32Set
Source§fn extend<U: IntoIterator<Item = u32>>(&mut self, iter: U)
fn extend<U: IntoIterator<Item = u32>>(&mut self, iter: U)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)