pub fn insert(
        &mut self,
        ids: &[Entity],
        arch: ArchetypeIndex,
        ComponentIndex(base): ComponentIndex,
    ) -> Vec<EntityLocation> {
        let mut current_block = u64::MAX;
        let mut block_vec = None;
        let mut removed = Vec::new();
        for (i, entity) in ids.iter().enumerate() {
            let block = entity.0.get() / BLOCK_SIZE;
            if current_block != block {
                block_vec = Some(
                    self.blocks
                        .entry(block)
                        .or_insert_with(|| Box::new([None; BLOCK_SIZE_USIZE])),
                );
                current_block = block;
            }

            if let Some(ref mut vec) = block_vec {
                let idx = (entity.0.get() % BLOCK_SIZE) as usize;
                let loc = EntityLocation(arch, ComponentIndex(base + i));
                if let Some(previous) = vec[idx].replace(loc) {
                    removed.push(previous);
                }
            }
        }

        self.len += ids.len() - removed.len();

        removed
    }
/// Inserts a collection of adjacent entities into the location map.
Inserts a collection of adjacent entities into the location map.
Inserts a collection of adjacent entities into the location map .
pub fn insert(
        &mut self,
        ids: &[Entity],
        arch: ArchetypeIndex,
        ComponentIndex(base): ComponentIndex,
    ) -> Vec<EntityLocation> {
        let mut current_block = u64::MAX;
        let mut block_vec = None;
        let mut removed = Vec::new();
        for (i, entity) in ids.iter().enumerate() {
            let block = entity.0.get() / BLOCK_SIZE;
            if current_block != block {
                block_vec = Some(
                    self.blocks
                        .entry(block)
                        .or_insert_with(|| Box::new([None; BLOCK_SIZE_USIZE])),
                );
                current_block = block;
            }
            if let Some(ref mut vec) = block_vec {
                let idx = (entity.0.get() % BLOCK_SIZE) as usize;
                let loc = EntityLocation(arch, ComponentIndex(base + i));
                if let Some(previous) = vec[idx].replace(loc) {
                    removed.push(previous);
                }
            }
        }
        self.len += ids.len() - removed.len();
        removed
    }
pub fn insert ( & mut self , ids : & [ Entity ] , arch : ArchetypeIndex , ComponentIndex ( base ) : ComponentIndex , ) -> Vec < EntityLocation > { let mut current_block = u64 :: MAX ; let mut block_vec = None ; let mut removed = Vec :: new ( ) ; for ( i , entity ) in ids . iter ( ) . enumerate ( ) { let block = entity . 0 . get ( ) / BLOCK_SIZE ; if current_block != block { block_vec = Some ( self . blocks . entry ( block ) . or_insert_with ( | | Box :: new ( [ None ; BLOCK_SIZE_USIZE ] ) ) , ) ; current_block = block ; } if let Some ( ref mut vec ) = block_vec { let idx = ( entity . 0 . get ( ) % BLOCK_SIZE ) as usize ; let loc = EntityLocation ( arch , ComponentIndex ( base + i ) ) ; if let Some ( previous ) = vec [ idx ] . replace ( loc ) { removed . push ( previous ) ; } } } self . len += ids . len ( ) - removed . len ( ) ; removed }
Inserts a collection of adjacent entities into the location map.
Inserts a collection of adjacent entities into the location map .
&mut self
ids
&[Entity]
arch
ComponentIndex
&mut self
ids
&[Entity]
arch
ComponentIndex