pub fn pack_to(
        &mut self,
        minimum_capacity: usize,
    ) -> HashMap<Index<EntryData>, Index<EntryData>> {
        assert!(
            minimum_capacity >= self.length,
            "cannot shrink to capacity lower than current length"
        );

        let mut count = 0;
        let mut entries = Vec::with_capacity(minimum_capacity);
        let generation = create_initial_generation();
        let length = self.length;
        let mut map = HashMap::with_capacity(length);
        let mut next_index = self.head();

        while let Some(index) = next_index {
            let mut entry = self.remove_entry(index).expect("expected occupied entry");
            next_index = entry.next;
            map.insert(
                Index::new(index, entry.generation),
                Index::new(count, generation),
            );

            entry.generation = generation;
            entry.previous = if count > 0 { Some(count - 1) } else { None };
            entry.next = if count < length - 1 {
                Some(count + 1)
            } else {
                None
            };

            entries.push(Entry::Occupied(entry));
            count += 1;
        }

        self.entries = entries;
        self.generation = generation;
        self.length = length;
        self.vacant_head = None;

        if self.length > 0 {
            self.set_head(0);
            self.set_tail(length - 1);
        } else {
            self.head = None;
            self.tail = None;
        }

        map
    }
/// Reorganizes the existing values to ensure maximum cache locality and shrinks the list such
/// that the capacity is exactly [`minimum_capacity`].
///
/// This function can be used to actually increase the capacity of the list.
///
/// Complexity: O(n)
///
/// # Panics
///
/// Panics if the given minimum capacity is less than the current length of the list.
///
/// # Examples
///
/// ```
/// use dlv_list::VecList;
///
/// let mut list = VecList::new();
/// let index_1 = list.push_back(5);
/// let index_2 = list.push_back(10);
/// let index_3 = list.push_front(100);
/// list.remove(index_1);
///
/// assert!(list.capacity() >= 3);
///
/// let mut map = list.pack_to(list.len() + 5);
/// assert_eq!(list.capacity(), 7);
/// assert_eq!(map.len(), 2);
///
/// let index_2 = map.remove(&index_2).unwrap();
/// let index_3 = map.remove(&index_3).unwrap();
///
/// assert_eq!(list.get(index_2), Some(&10));
/// assert_eq!(list.get(index_3), Some(&100));
///
/// let mut iter = list.iter();
/// assert_eq!(iter.next(), Some(&100));
/// assert_eq!(iter.next(), Some(&10));
/// assert_eq!(iter.next(), None);
/// ```
Reorganizes the existing values to ensure maximum cache locality and shrinks the list such
that the capacity is exactly [`minimum_capacity`].

This function can be used to actually increase the capacity of the list.


Reorganizes the existing values to ensure maximum cache locality and shrinks the list such that the capacity is exactly [ ` minimum_capacity ` ] . This function can be used to actually increase the capacity of the list .
pub fn pack_to(
        &mut self,
        minimum_capacity: usize,
    ) -> HashMap<Index<EntryData>, Index<EntryData>> {
        assert!(
            minimum_capacity >= self.length,
            "cannot shrink to capacity lower than current length"
        );
        let mut count = 0;
        let mut entries = Vec::with_capacity(minimum_capacity);
        let generation = create_initial_generation();
        let length = self.length;
        let mut map = HashMap::with_capacity(length);
        let mut next_index = self.head();
        while let Some(index) = next_index {
            let mut entry = self.remove_entry(index).expect("expected occupied entry");
            next_index = entry.next;
            map.insert(
                Index::new(index, entry.generation),
                Index::new(count, generation),
            );
            entry.generation = generation;
            entry.previous = if count > 0 { Some(count - 1) } else { None };
            entry.next = if count < length - 1 {
                Some(count + 1)
            } else {
                None
            };
            entries.push(Entry::Occupied(entry));
            count += 1;
        }
        self.entries = entries;
        self.generation = generation;
        self.length = length;
        self.vacant_head = None;
        if self.length > 0 {
            self.set_head(0);
            self.set_tail(length - 1);
        } else {
            self.head = None;
            self.tail = None;
        }
        map
    }
pub fn pack_to ( & mut self , minimum_capacity : usize , ) -> HashMap < Index < EntryData > , Index < EntryData > > { assert ! ( minimum_capacity self length " " ) ; let mut count = 0 ; let mut entries = Vec :: with_capacity ( minimum_capacity ) ; let generation = create_initial_generation ( ) ; let length = self . length ; let mut map = HashMap :: with_capacity ( length ) ; let mut next_index = self . head ( ) ; while let Some ( index ) = next_index { let mut entry = self . remove_entry ( index ) . expect ( " " ) ; next_index = entry . next ; map . insert ( Index :: new ( index , entry . generation ) , Index :: new ( count , generation ) , ) ; entry . generation = generation ; entry . previous = if count > 0 { Some ( count - 1 ) } else { None } ; entry . next = if count < length - 1 { Some ( count + 1 ) } else { None } ; entries . push ( Entry :: Occupied ( entry ) ) ; count += 1 ; } self . entries = entries ; self . generation = generation ; self . length = length ; self . vacant_head = None ; if self . length > 0 { self . set_head ( 0 ) ; self . set_tail ( length - 1 ) ; } else { self . head = None ; self . tail = None ; } map }
Reorganizes the existing values to ensure maximum cache locality and shrinks the list such
that the capacity is exactly [`minimum_capacity`].
Reorganizes the existing values to ensure maximum cache locality and shrinks the list such that the capacity is exactly [ ` minimum_capacity ` ] .
&mut self
minimum_capacity
usize
&mut self
minimum_capacity
usize
panics
Panics if the given minimum capacity is less than the current length of the list.
Panics if the given minimum capacity is less than the current length of the list .
examples
```
use dlv_list::VecList.





let mut map = list.pack_to(list.len() + 5);
assert_eq!(list.capacity(), 7);
assert_eq!(map.len(), 2).

let index_2 = map.remove(&index_2).unwrap();
let index_3 = map.remove(&index_3).unwrap().




` ` ` use dlv_list :: VecList . let mut map = list . pack_to ( list . len () + 5 ) ; assert_eq! ( list . capacity () 7 ) ; assert_eq! ( map . len () 2 ) . let index_2 = map . remove ( &index_2 ) . unwrap () ; let index_3 = map . remove ( &index_3 ) . unwrap () .