Skip to main content

LogosBits

Struct LogosBits 

Source
pub struct LogosBits { /* private fields */ }
Expand description

A Seq of Bool held one bit per item: the representation a local sequence of truth values takes when every use of it is an item read, an item store, a push or its length. A table of n flags takes n / 8 bytes where a Vec<bool> takes n, so a sieve over 10^8 numbers fits in the cache it used to stream past.

Items are counted from 1 as in every sequence, through crate::resolve_logos_index: an index counted from the back reaches the same item, and one that names no item fails with the sentence every tier reports. The unchecked accessors take a 0-based offset the caller has proven below LogosBits::len.

Implementations§

Source§

impl LogosBits

Source

pub fn new() -> Self

Source

pub fn with_capacity(items: usize) -> Self

An empty sequence with room for items items before it grows.

Source

pub fn filled(len: usize, value: bool) -> Self

len items, each value.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn push(&mut self, value: bool)

Source

pub fn item(&self, index: i64) -> bool

The item index names (counted from 1, or from the back when negative).

Source

pub fn set_item(&mut self, index: i64, value: bool)

Store value as the item index names.

Source

pub unsafe fn get_unchecked(&self, offset: usize) -> bool

The item at 0-based offset.

§Safety

offset is below LogosBits::len.

Source

pub unsafe fn set_unchecked(&mut self, offset: usize, value: bool)

Store value at 0-based offset.

§Safety

offset is below LogosBits::len.

Source

pub unsafe fn set_true_unchecked(&mut self, offset: usize)

Store true at 0-based offset: one or into its word.

§Safety

offset is below LogosBits::len.

Source

pub unsafe fn fill_stride_unchecked( &mut self, first: usize, count: usize, step: usize, value: bool, )

Store value at the count offsets first, first + step, first + 2 * step, ….

A step of a word or more puts each offset in a word of its own, and a handful of offsets cost no more one at a time; both store in place. Otherwise Self::fill_stride_words writes each word the progression crosses once, out of line, so a loop that fills now and then keeps none of the walk’s state in its own registers.

§Safety

step is at least 1 and, when count is not 0, first + (count - 1) * step is below LogosBits::len.

Source

pub unsafe fn fill_stride_through_unchecked( &mut self, first: usize, through: usize, step: usize, value: bool, ) -> usize

Store value at first, first + step, … up to through, and return how many steps past first that took: a loop’s stores from its counter’s value on entry to its bound, the bound given as the offset it would store at. Out of line, so the loop that calls it keeps no arithmetic of the progression in its own registers: what it computes from its counter is the counter.

§Safety

step is at least 1, first <= through, and first + (through - first) / step * step is below LogosBits::len.

Source

pub fn iter(&self) -> impl Iterator<Item = bool> + '_

The items, first to last.

Trait Implementations§

Source§

impl Clone for LogosBits

Source§

fn clone(&self) -> LogosBits

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogosBits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LogosBits

Source§

fn default() -> LogosBits

Returns the “default value” for a type. Read more
Source§

impl PartialEq for LogosBits

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LogosBits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.