Struct libbgs::numbers::FactorTrie

source ·
pub struct FactorTrie<S, const L: usize, C, T> {
    pub data: T,
    /* private fields */
}
Expand description

A trie of prime factors in increasing order; that is, a none with word $p$ will have only children with word $q \geq p$.

Fields§

§data: T

Data associated with the key given by the concatenation of this node’s ancestors’ words.

Implementations§

source§

impl<S, const L: usize, C> FactorTrie<S, L, C, ()>where C: Factor<S>,

source

pub fn new() -> FactorTrie<S, L, C, ()>

Creates a new trie associated to the given factorization. The trie contains the divisors of C::FACTORS. The words of a divisor are its prime factors, with multiplicities, in ascending order.

source§

impl<S, const L: usize, C, T> FactorTrie<S, L, C, T>where C: Factor<S>,

source

pub fn new_with<F>(f: F) -> FactorTrie<S, L, C, T>where F: Fn(&[usize; L], usize) -> T,

Creates a new trie associated to the given factorization. The trie contains the divisors of C::FACTORS. The words of a divisor are its prime factors, with multiplicities, in ascending order. The trie is seeded with data generated by f.

source§

impl<S, const L: usize, C, T> FactorTrie<S, L, C, T>

source

pub fn get_or_new_child<F>( &mut self, i: usize, data: F ) -> &mut FactorTrie<S, L, C, T>where F: FnOnce() -> T,

Returns this node’s child at index i, or creates the child, initialized with the result of the lazily-evaluated data.

source

pub fn update<F>(&mut self, t: &[usize; L], gen: F)where F: Fn(&[usize; L], &mut T),

Updates a single node in the trie.

source

pub fn map<U, F>(self, f: &F) -> FactorTrie<S, L, C, U>where F: Fn(T, &[usize; L], usize) -> U,

Transforms this trie into an equivalent trie with the same shape, but all data mapped via f.

source

pub fn as_ref(&self) -> FactorTrie<S, L, C, &T>

Returns a trie of borrowed data.

source

pub fn as_mut(&mut self) -> FactorTrie<S, L, C, &mut T>

Returns a trie of mutably borrowed data.

source

pub fn for_each<F>(&self, f: &mut F)where F: FnMut(&T, [usize; L]),

Runs f on each node, in a pre-order traversal.

source

pub fn index(&self) -> usize

The index of this node’s word in the prime factorization array.

source

pub fn ds(&self) -> &[usize; L]

The array of powers on this node’s prime factoraziton.

source

pub fn children(&self) -> &[Option<Box<FactorTrie<S, L, C, T>>>]

This node’s array of children.

source

pub fn child(&self, i: usize) -> Option<&FactorTrie<S, L, C, T>>

Returns a reference to the child at index i, if there is one.

source

pub fn child_mut(&mut self, i: usize) -> Option<&mut FactorTrie<S, L, C, T>>

Returns a mutable reference to the child at index i, if there is one.

Trait Implementations§

source§

impl<S, const L: usize, C, T: Clone> Clone for FactorTrie<S, L, C, T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S, const L: usize, C, T> RefUnwindSafe for FactorTrie<S, L, C, T>where C: RefUnwindSafe, S: RefUnwindSafe, T: RefUnwindSafe,

§

impl<S, const L: usize, C, T> Send for FactorTrie<S, L, C, T>where C: Send, S: Send, T: Send,

§

impl<S, const L: usize, C, T> Sync for FactorTrie<S, L, C, T>where C: Sync, S: Sync, T: Sync,

§

impl<S, const L: usize, C, T> Unpin for FactorTrie<S, L, C, T>where C: Unpin, S: Unpin, T: Unpin,

§

impl<S, const L: usize, C, T> UnwindSafe for FactorTrie<S, L, C, T>where C: UnwindSafe, S: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.