// Find the specified number of accounts with lowest balances so that their
// balances can be reclaimed.
Find the specified number of accounts with lowest balances so that their
balances can be reclaimed.
Find the specified number of accounts with lowest balances so that their balances can be reclaimed .
fn select_accounts_to_trim(&mut self, num_accounts: usize) -> Vec<(Tokens, AccountIdentifier)> {
        let mut to_trim: std::collections::BinaryHeap<(Tokens, AccountIdentifier)> =
            std::collections::BinaryHeap::new();
        let mut iter = self.store.iter();
        // Accumulate up to `trim_quantity` accounts
        for (account, balance) in iter.by_ref().take(num_accounts) {
            to_trim.push((*balance, *account));
        }
        for (account, balance) in iter {
            // If any account's balance is lower than the maximum in our set,
            // include that account, and remove the current maximum
            if let Some((greatest_balance, _)) = to_trim.peek() {
                if balance < greatest_balance {
                    to_trim.push((*balance, *account));
                    to_trim.pop();
                }
            }
        }
        to_trim.into_vec()
    }
fn select_accounts_to_trim ( & mut self , num_accounts : usize ) -> Vec < ( Tokens , AccountIdentifier ) > { let mut to_trim : std :: collections :: BinaryHeap < ( Tokens , AccountIdentifier ) > = std :: collections :: BinaryHeap :: new ( ) ; let mut iter = self . store . iter ( ) ; // Accumulate up to `trim_quantity` accounts for ( account , balance ) in iter . by_ref ( ) . take ( num_accounts ) { to_trim . push ( ( * balance , * account ) ) ; } for ( account , balance ) in iter { // If any account's balance is lower than the maximum in our set, // include that account, and remove the current maximum if let Some ( ( greatest_balance , _ ) ) = to_trim . peek ( ) { if balance < greatest_balance { to_trim . push ( ( * balance , * account ) ) ; to_trim . pop ( ) ; } } } to_trim . into_vec ( ) }
Find the specified number of accounts with lowest balances so that their
balances can be reclaimed.
Find the specified number of accounts with lowest balances so that their balances can be reclaimed .
&mut self
num_accounts
usize