fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
                                mut displacement: usize,
                                mut hash: SafeHash,
                                mut key: K,
                                mut val: V)
                                -> FullBucketMut<'a, K, V> {
    let size = bucket.table().size();
    let raw_capacity = bucket.table().capacity();
    // There can be at most `size - dib` buckets to displace, because
    // in the worst case, there are `size` elements and we already are
    // `displacement` buckets away from the initial one.
    let idx_end = (bucket.index() + size - bucket.displacement()) % raw_capacity;
    // Save the *starting point*.
    let mut bucket = bucket.stash();

    loop {
        let (old_hash, old_key, old_val) = bucket.replace(hash, key, val);
        hash = old_hash;
        key = old_key;
        val = old_val;

        loop {
            displacement += 1;
            let probe = bucket.next();
            debug_assert!(probe.index() != idx_end);

            let full_bucket = match probe.peek() {
                Empty(bucket) => {
                    // Found a hole!
                    let bucket = bucket.put(hash, key, val);
                    // Now that it's stolen, just read the value's pointer
                    // right out of the table! Go back to the *starting point*.
                    //
                    // This use of `into_table` is misleading. It turns the
                    // bucket, which is a FullBucket on top of a
                    // FullBucketMut, into just one FullBucketMut. The "table"
                    // refers to the inner FullBucketMut in this context.
                    return bucket.into_table();
                }
                Full(bucket) => bucket,
            };

            let probe_displacement = full_bucket.displacement();

            bucket = full_bucket;

            // Robin hood! Steal the spot.
            if probe_displacement < displacement {
                displacement = probe_displacement;
                break;
            }
        }
    }
}
/// Perform robin hood bucket stealing at the given `bucket`. You must
/// also pass that bucket's displacement so we don't have to recalculate it.
///
/// `hash`, `key`, and `val` are the elements to "robin hood" into the hashtable.
Perform robin hood bucket stealing at the given `bucket`. You must
also pass that bucket's displacement so we don't have to recalculate it.


Perform robin hood bucket stealing at the given ` bucket ` . You must also pass that bucket ' s displacement so we don ' t have to recalculate it .
fn robin_hood<'a, K: 'a, V: 'a>(bucket: FullBucketMut<'a, K, V>,
                                mut displacement: usize,
                                mut hash: SafeHash,
                                mut key: K,
                                mut val: V)
                                -> FullBucketMut<'a, K, V> {
    let size = bucket.table().size();
    let raw_capacity = bucket.table().capacity();
    // There can be at most `size - dib` buckets to displace, because
    // in the worst case, there are `size` elements and we already are
    // `displacement` buckets away from the initial one.
    let idx_end = (bucket.index() + size - bucket.displacement()) % raw_capacity;
    // Save the *starting point*.
    let mut bucket = bucket.stash();
    loop {
        let (old_hash, old_key, old_val) = bucket.replace(hash, key, val);
        hash = old_hash;
        key = old_key;
        val = old_val;
        loop {
            displacement += 1;
            let probe = bucket.next();
            debug_assert!(probe.index() != idx_end);
            let full_bucket = match probe.peek() {
                Empty(bucket) => {
                    // Found a hole!
                    let bucket = bucket.put(hash, key, val);
                    // Now that it's stolen, just read the value's pointer
                    // right out of the table! Go back to the *starting point*.
                    //
                    // This use of `into_table` is misleading. It turns the
                    // bucket, which is a FullBucket on top of a
                    // FullBucketMut, into just one FullBucketMut. The "table"
                    // refers to the inner FullBucketMut in this context.
                    return bucket.into_table();
                }
                Full(bucket) => bucket,
            };
            let probe_displacement = full_bucket.displacement();
            bucket = full_bucket;
            // Robin hood! Steal the spot.
            if probe_displacement < displacement {
                displacement = probe_displacement;
                break;
            }
        }
    }
}
fn robin_hood < ' a , K : ' a , V : ' a > ( bucket : FullBucketMut < ' a , K , V > , mut displacement : usize , mut hash : SafeHash , mut key : K , mut val : V ) -> FullBucketMut < ' a , K , V > { let size = bucket . table ( ) . size ( ) ; let raw_capacity = bucket . table ( ) . capacity ( ) ; // There can be at most `size - dib` buckets to displace, because // in the worst case, there are `size` elements and we already are // `displacement` buckets away from the initial one. let idx_end = ( bucket . index ( ) + size - bucket . displacement ( ) ) % raw_capacity ; // Save the *starting point*. let mut bucket = bucket . stash ( ) ; loop { let ( old_hash , old_key , old_val ) = bucket . replace ( hash , key , val ) ; hash = old_hash ; key = old_key ; val = old_val ; loop { displacement += 1 ; let probe = bucket . next ( ) ; debug_assert ! ( probe index ( ) idx_end ) ; let full_bucket = match probe . peek ( ) { Empty ( bucket ) => { // Found a hole! let bucket = bucket . put ( hash , key , val ) ; // Now that it's stolen, just read the value's pointer // right out of the table! Go back to the *starting point*. // // This use of `into_table` is misleading. It turns the // bucket, which is a FullBucket on top of a // FullBucketMut, into just one FullBucketMut. The "table" // refers to the inner FullBucketMut in this context. return bucket . into_table ( ) ; } Full ( bucket ) => bucket , } ; let probe_displacement = full_bucket . displacement ( ) ; bucket = full_bucket ; // Robin hood! Steal the spot. if probe_displacement < displacement { displacement = probe_displacement ; break ; } } } }
Perform robin hood bucket stealing at the given `bucket`.
Perform robin hood bucket stealing at the given ` bucket ` .
bucket
FullBucketMut<'a, K, V>
displacement
usize
hash
SafeHash
key
K
val
V