pub fn split_off(&mut self, at: usize) -> Vob<T> {
        debug_assert_eq!(self.vec.len(), blocks_required::<T>(self.len));
        if at >= self.len {
            // Return empty Vob
            return Vob::<T>::new_with_storage_type(0);
        } else if at == 0 {
            // efficiently swap structs
            let mut result = Vob::<T>::new_with_storage_type(0);
            result.vec = replace(&mut self.vec, result.vec);
            result.len = replace(&mut self.len, result.len);
            debug_assert_eq!(self.len, 0);
            debug_assert_eq!(self.vec.len(), 0);
            return result;
        }

        let block_to_split = blocks_required::<T>(at) - 1;
        let ub = at % bits_per_block::<T>();

        let mut nv = Vob::<T>::new_with_storage_type(self.len - at);

        // If ub == 0, we shouldn't copy block_to_split into the new Vob, because it fully fits
        // into the old Vob.
        if ub > 0 {
            // The number of bits from block_to_split that end up in the new Vob
            let first_block_len = if bits_per_block::<T>() - ub > self.len - at {
                self.len - at
            } else {
                bits_per_block::<T>() - ub
            };

            nv.vec.push(self.vec[block_to_split] >> ub);
            nv.len = first_block_len;
            nv.mask_last_block();
        }

        // We only need to do this if there are blocks remaining
        if self.vec.len() > block_to_split + 1 {
            nv.extend_blocks(self, block_to_split + 1);
        }

        self.truncate(at);
        nv
    }
/// Splits the collection into two at the given index.
///
/// Returns a newly allocated Self. self contains elements [0, at), and the returned Self
/// contains elements [at, len).
///
/// Note that the capacity of self does not change.
///
/// # Examples
/// ```
/// use vob::Vob;
/// let mut v1 = Vob::new();
/// v1.push(true);
/// v1.push(false);
/// let v2 = v1.split_off(1);
/// assert_eq!(v1, Vob::from_elem(true, 1));
/// assert_eq!(v2, Vob::from_elem(false, 1));
/// ```
Splits the collection into two at the given index.
Returns a newly allocated Self. self contains elements [0, at), and the returned Self
contains elements [at, len).

Note that the capacity of self does not change.
Splits the collection into two at the given index . Returns a newly allocated Self . self contains elements [ 0 at ) and the returned Self contains elements [ at len ) . Note that the capacity of self does not change .
pub fn split_off(&mut self, at: usize) -> Vob<T> {
        debug_assert_eq!(self.vec.len(), blocks_required::<T>(self.len));
        if at >= self.len {
            // Return empty Vob
            return Vob::<T>::new_with_storage_type(0);
        } else if at == 0 {
            // efficiently swap structs
            let mut result = Vob::<T>::new_with_storage_type(0);
            result.vec = replace(&mut self.vec, result.vec);
            result.len = replace(&mut self.len, result.len);
            debug_assert_eq!(self.len, 0);
            debug_assert_eq!(self.vec.len(), 0);
            return result;
        }
        let block_to_split = blocks_required::<T>(at) - 1;
        let ub = at % bits_per_block::<T>();
        let mut nv = Vob::<T>::new_with_storage_type(self.len - at);
        // If ub == 0, we shouldn't copy block_to_split into the new Vob, because it fully fits
        // into the old Vob.
        if ub > 0 {
            // The number of bits from block_to_split that end up in the new Vob
            let first_block_len = if bits_per_block::<T>() - ub > self.len - at {
                self.len - at
            } else {
                bits_per_block::<T>() - ub
            };
            nv.vec.push(self.vec[block_to_split] >> ub);
            nv.len = first_block_len;
            nv.mask_last_block();
        }
        // We only need to do this if there are blocks remaining
        if self.vec.len() > block_to_split + 1 {
            nv.extend_blocks(self, block_to_split + 1);
        }
        self.truncate(at);
        nv
    }
pub fn split_off ( & mut self , at : usize ) -> Vob < T > { debug_assert_eq ! ( self vec len ( ) blocks_required T ( self len ) ) ; if at >= self . len { // Return empty Vob return Vob :: < T > :: new_with_storage_type ( 0 ) ; } else if at == 0 { // efficiently swap structs let mut result = Vob :: < T > :: new_with_storage_type ( 0 ) ; result . vec = replace ( & mut self . vec , result . vec ) ; result . len = replace ( & mut self . len , result . len ) ; debug_assert_eq ! ( self len 0 ) ; debug_assert_eq ! ( self vec len ( ) 0 ) ; return result ; } let block_to_split = blocks_required :: < T > ( at ) - 1 ; let ub = at % bits_per_block :: < T > ( ) ; let mut nv = Vob :: < T > :: new_with_storage_type ( self . len - at ) ; // If ub == 0, we shouldn't copy block_to_split into the new Vob, because it fully fits // into the old Vob. if ub > 0 { // The number of bits from block_to_split that end up in the new Vob let first_block_len = if bits_per_block :: < T > ( ) - ub > self . len - at { self . len - at } else { bits_per_block :: < T > ( ) - ub } ; nv . vec . push ( self . vec [ block_to_split ] >> ub ) ; nv . len = first_block_len ; nv . mask_last_block ( ) ; } // We only need to do this if there are blocks remaining if self . vec . len ( ) > block_to_split + 1 { nv . extend_blocks ( self , block_to_split + 1 ) ; } self . truncate ( at ) ; nv }
Splits the collection into two at the given index.
Splits the collection into two at the given index .
&mut self
at
usize
&mut self
at
usize
examples
None