fn precompute_assorted_nodes(
    buckets: &[Bucket],
    self_node_id: NodeId,
) -> Option<[(usize, &Node, bool); bucket::MAX_BUCKET_SIZE]> {
    if buckets.len() == MAX_BUCKETS {
        return None;
    }
    let assorted_bucket = &buckets[buckets.len() - 1];
    let mut assorted_iter = assorted_bucket.iter().peekable();

    // So the bucket is not empty and now we have a reference to initialize our stack allocated array.
    if let Some(&init_reference) = assorted_iter.peek() {
        // Set all tuples to true in case our bucket is not full.
        let mut assorted_nodes = [(0, init_reference, true); bucket::MAX_BUCKET_SIZE];

        for (index, node) in assorted_iter.enumerate() {
            let bucket_index = leading_bit_count(self_node_id, node.id());

            assorted_nodes[index] = (bucket_index, node, false);
        }

        Some(assorted_nodes)
    } else {
        None
    }
}
/// Optionally returns the precomputed bucket positions for all assorted nodes.
Optionally returns the precomputed bucket positions for all assorted nodes.
Optionally returns the precomputed bucket positions for all assorted nodes .
fn precompute_assorted_nodes(
    buckets: &[Bucket],
    self_node_id: NodeId,
) -> Option<[(usize, &Node, bool); bucket::MAX_BUCKET_SIZE]> {
    if buckets.len() == MAX_BUCKETS {
        return None;
    }
    let assorted_bucket = &buckets[buckets.len() - 1];
    let mut assorted_iter = assorted_bucket.iter().peekable();
    // So the bucket is not empty and now we have a reference to initialize our stack allocated array.
    if let Some(&init_reference) = assorted_iter.peek() {
        // Set all tuples to true in case our bucket is not full.
        let mut assorted_nodes = [(0, init_reference, true); bucket::MAX_BUCKET_SIZE];
        for (index, node) in assorted_iter.enumerate() {
            let bucket_index = leading_bit_count(self_node_id, node.id());
            assorted_nodes[index] = (bucket_index, node, false);
        }
        Some(assorted_nodes)
    } else {
        None
    }
}
fn precompute_assorted_nodes ( buckets : & [ Bucket ] , self_node_id : NodeId , ) -> Option < [ ( usize , & Node , bool ) ; bucket :: MAX_BUCKET_SIZE ] > { if buckets . len ( ) == MAX_BUCKETS { return None ; } let assorted_bucket = & buckets [ buckets . len ( ) - 1 ] ; let mut assorted_iter = assorted_bucket . iter ( ) . peekable ( ) ; // So the bucket is not empty and now we have a reference to initialize our stack allocated array. if let Some ( & init_reference ) = assorted_iter . peek ( ) { // Set all tuples to true in case our bucket is not full. let mut assorted_nodes = [ ( 0 , init_reference , true ) ; bucket :: MAX_BUCKET_SIZE ] ; for ( index , node ) in assorted_iter . enumerate ( ) { let bucket_index = leading_bit_count ( self_node_id , node . id ( ) ) ; assorted_nodes [ index ] = ( bucket_index , node , false ) ; } Some ( assorted_nodes ) } else { None } }
Optionally returns the precomputed bucket positions for all assorted nodes.
Optionally returns the precomputed bucket positions for all assorted nodes .
buckets
&[Bucket]
self_node_id
NodeId
buckets
&[Bucket]
self_node_id
NodeId