pub fn shrink_to_fit(&mut self) {
        let limit = hash_table::calc_limit(self.len());
        let old_cap = self.capacity();
        let new_cap = {
            let mut tmp = old_cap / 2;
            let mut res = old_cap;
            while tmp >= limit {
                res = tmp;
                tmp /= 2;
            }
            res
        };
        if new_cap >= old_cap {
            return;
        }
        let mut new_entry_fastbin = Fastbin::new(mem::size_of::<InternalHashEntry<K, V>>());
        let mut new_kv_fastbin = Fastbin::new(mem::size_of::<(K, V)>());
        let mut new_hash_table = hash_table::HashTable::new_with_box();
        new_hash_table.rehash(self.len());
        let mut new_kv_vec = Vec::with_capacity(self.len());
        {
            let mut destroy_callback = |(k, v): (K, V)| {
                let kv_ptr = kv_alloc(&mut new_kv_fastbin, k, v);
                new_kv_vec.push(kv_ptr);
            };
            loop {
                let node = self.hash_table.pop_first_index();
                if node.is_null() {
                    break;
                }
                self.recurse_destroy(node, &mut destroy_callback);
            }
            debug_assert_eq!(self.hash_table.size(), 0);
        }
        for kv_ptr in new_kv_vec {
            unsafe {
                let key_ptr = &mut (*kv_ptr).0 as *mut K;
                let value_ptr = &mut (*kv_ptr).1 as *mut V;
                let entry = entry_alloc(
                    &mut new_entry_fastbin,
                    key_ptr,
                    value_ptr,
                    self.make_hash(&(*key_ptr)),
                );
                hash_table_update(&mut new_hash_table, entry);
            }
        }
        self.kv_fastbin = new_kv_fastbin;
        self.entry_fastbin = new_entry_fastbin;
        self.hash_table = new_hash_table;
    }
/// Shrinks the capacity of the map as much as possible. It will drop
/// down as much as possible while maintaining the internal rules
/// and possibly leaving some space in accordance with the resize policy.
///
/// # Examples
///
/// ```
/// use hash_ord::hash_map::HashMap;
///
/// let mut map: HashMap<isize, isize> = HashMap::with_capacity(100);
/// map.insert(1, 2);
/// map.insert(3, 4);
/// assert!(map.capacity() >= 100);
/// map.shrink_to_fit();
/// assert!(map.capacity() >= 2);
/// ```
Shrinks the capacity of the map as much as possible. It will drop
down as much as possible while maintaining the internal rules
and possibly leaving some space in accordance with the resize policy.
Shrinks the capacity of the map as much as possible . It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy .
pub fn shrink_to_fit(&mut self) {
        let limit = hash_table::calc_limit(self.len());
        let old_cap = self.capacity();
        let new_cap = {
            let mut tmp = old_cap / 2;
            let mut res = old_cap;
            while tmp >= limit {
                res = tmp;
                tmp /= 2;
            }
            res
        };
        if new_cap >= old_cap {
            return;
        }
        let mut new_entry_fastbin = Fastbin::new(mem::size_of::<InternalHashEntry<K, V>>());
        let mut new_kv_fastbin = Fastbin::new(mem::size_of::<(K, V)>());
        let mut new_hash_table = hash_table::HashTable::new_with_box();
        new_hash_table.rehash(self.len());
        let mut new_kv_vec = Vec::with_capacity(self.len());
        {
            let mut destroy_callback = |(k, v): (K, V)| {
                let kv_ptr = kv_alloc(&mut new_kv_fastbin, k, v);
                new_kv_vec.push(kv_ptr);
            };
            loop {
                let node = self.hash_table.pop_first_index();
                if node.is_null() {
                    break;
                }
                self.recurse_destroy(node, &mut destroy_callback);
            }
            debug_assert_eq!(self.hash_table.size(), 0);
        }
        for kv_ptr in new_kv_vec {
            unsafe {
                let key_ptr = &mut (*kv_ptr).0 as *mut K;
                let value_ptr = &mut (*kv_ptr).1 as *mut V;
                let entry = entry_alloc(
                    &mut new_entry_fastbin,
                    key_ptr,
                    value_ptr,
                    self.make_hash(&(*key_ptr)),
                );
                hash_table_update(&mut new_hash_table, entry);
            }
        }
        self.kv_fastbin = new_kv_fastbin;
        self.entry_fastbin = new_entry_fastbin;
        self.hash_table = new_hash_table;
    }
pub fn shrink_to_fit ( & mut self ) { let limit = hash_table :: calc_limit ( self . len ( ) ) ; let old_cap = self . capacity ( ) ; let new_cap = { let mut tmp = old_cap / 2 ; let mut res = old_cap ; while tmp >= limit { res = tmp ; tmp /= 2 ; } res } ; if new_cap >= old_cap { return ; } let mut new_entry_fastbin = Fastbin :: new ( mem :: size_of :: < InternalHashEntry < K , V > > ( ) ) ; let mut new_kv_fastbin = Fastbin :: new ( mem :: size_of :: < ( K , V ) > ( ) ) ; let mut new_hash_table = hash_table :: HashTable :: new_with_box ( ) ; new_hash_table . rehash ( self . len ( ) ) ; let mut new_kv_vec = Vec :: with_capacity ( self . len ( ) ) ; { let mut destroy_callback = | ( k , v ) : ( K , V ) | { let kv_ptr = kv_alloc ( & mut new_kv_fastbin , k , v ) ; new_kv_vec . push ( kv_ptr ) ; } ; loop { let node = self . hash_table . pop_first_index ( ) ; if node . is_null ( ) { break ; } self . recurse_destroy ( node , & mut destroy_callback ) ; } debug_assert_eq ! ( self hash_table size ( ) 0 ) ; } for kv_ptr in new_kv_vec { unsafe { let key_ptr = & mut ( * kv_ptr ) . 0 as * mut K ; let value_ptr = & mut ( * kv_ptr ) . 1 as * mut V ; let entry = entry_alloc ( & mut new_entry_fastbin , key_ptr , value_ptr , self . make_hash ( & ( * key_ptr ) ) , ) ; hash_table_update ( & mut new_hash_table , entry ) ; } } self . kv_fastbin = new_kv_fastbin ; self . entry_fastbin = new_entry_fastbin ; self . hash_table = new_hash_table ; }
Shrinks the capacity of the map as much as possible.
Shrinks the capacity of the map as much as possible .
&mut self
examples
```
use hash_ord::hash_map::HashMap.


` ` ` use hash_ord :: hash_map :: HashMap .