Skip to content

Commit c71f720

Browse files
committed
Rename 'distance' -> 'displacement'
1 parent d31d8a9 commit c71f720

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libstd/collections/hash/map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn pop_internal<K, V>(starting_bucket: FullBucketMut<K, V>) -> (K, V) {
393393
None => return (retkey, retval)
394394
};
395395

396-
while gap.full().distance() != 0 {
396+
while gap.full().displacement() != 0 {
397397
gap = match gap.shift() {
398398
Some(b) => b,
399399
None => break
@@ -423,7 +423,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(mut bucket: FullBucketMut<'a, K, V>,
423423
// There can be at most `size - dib` buckets to displace, because
424424
// in the worst case, there are `size` elements and we already are
425425
// `distance` buckets away from the initial one.
426-
let idx_end = starting_index + size - bucket.distance();
426+
let idx_end = starting_index + size - bucket.displacement();
427427

428428
loop {
429429
let (old_hash, old_key, old_val) = bucket.replace(hash, k, v);
@@ -446,7 +446,7 @@ fn robin_hood<'a, K: 'a, V: 'a>(mut bucket: FullBucketMut<'a, K, V>,
446446
Full(bucket) => bucket
447447
};
448448

449-
let probe_ib = full_bucket.index() - full_bucket.distance();
449+
let probe_ib = full_bucket.index() - full_bucket.displacement();
450450

451451
bucket = full_bucket;
452452

@@ -731,7 +731,7 @@ impl<K, V, S> HashMap<K, V, S>
731731
loop {
732732
bucket = match bucket.peek() {
733733
Full(full) => {
734-
if full.distance() == 0 {
734+
if full.displacement() == 0 {
735735
// This bucket occupies its ideal spot.
736736
// It indicates the start of another "cluster".
737737
bucket = full.into_bucket();

src/libstd/collections/hash/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<K, V, M: Deref<Target=RawTable<K, V>>> FullBucket<K, V, M> {
370370
///
371371
/// In the cited blog posts above, this is called the "distance to
372372
/// initial bucket", or DIB. Also known as "probe count".
373-
pub fn distance(&self) -> usize {
373+
pub fn displacement(&self) -> usize {
374374
// Calculates the distance one has to travel when going from
375375
// `hash mod capacity` onwards to `idx mod capacity`, wrapping around
376376
// if the destination is not reached before the end of the table.

0 commit comments

Comments
 (0)