   internal func clear() {
     if bucketCount < Word.capacity {
       // We have only a single partial word. Set all out of bounds bits, so that
-      // `index(after:)` and `nextHole(atOrAfter:)` works correctly without a
-      // special case.
+      // `occupiedBucket(after:)` and `nextHole(atOrAfter:)` works correctly
+      // without a special case.
       words[0] = Word.allBits.subtracting(elementsBelow: bucketCount)
     } else {
       words.assign(repeating: .empty, count: wordCount)

extension _HashTable {
  @inlinable
  @inline(__always)
  internal func isValid(_ index: Index) -> Bool {
    return index.bucket >= 0 && index.bucket < bucketCount
  }

  @inlinable
  @inline(__always)
  internal func _isOccupied(_ index: Index) -> Bool {
    _sanityCheck(isValid(index))
    return words[index.word].uncheckedContains(index.bit)
  }

  @inlinable
  @inline(__always)
  internal func isOccupied(_ index: Index) -> Bool {
    return isValid(index) && _isOccupied(index)
  }

  @inlinable
  @inline(__always)
  internal func checkOccupied(_ i: Index) {
    _precondition(isOccupied(i),
      "Attempting to access Collection elements using an invalid Index")
  }

  @inlinable
  @inline(__always)
  internal func _firstOccupiedIndex(fromWord word: Int) -> Index {
    _sanityCheck(word >= 0 && word <= wordCount)
    var word = word
    while word < wordCount {
      if let bit = words[word].minimum {
        return Index(word: word, bit: bit)
      }
      word += 1
    }
    return endIndex
  }

  @inlinable
  internal func index(after index: Index) -> Index {
    _sanityCheck(isValid(index))
    let word = index.word
    if let bit = words[word].intersecting(elementsAbove: index.bit).minimum {
      return Index(word: word, bit: bit)
    }
    return _firstOccupiedIndex(fromWord: word + 1)
  }

  @inlinable
  internal var startIndex: Index {
    return _firstOccupiedIndex(fromWord: 0)
  }

  @inlinable
  internal var endIndex: Index {
    @inline(__always)
    get {
      return Index(bucket: bucketCount)
    }
  }
}

extension _HashTable {
  @inlinable
  @inline(__always)
  internal func idealIndex(forHashValue hashValue: Int) -> Index {
    return Index(bucket: hashValue & bucketMask)
  }

  /// The next bucket after `bucket`, with wraparound at the end of the table.
  @inlinable
  @inline(__always)
  internal func index(wrappedAfter index: Index) -> Index {
    // The bucket is less than bucketCount, which is power of two less than
    // Int.max. Therefore adding 1 does not overflow.
    return Index(bucket: (index.bucket &+ 1) & bucketMask)
  }
}

extension _HashTable {
  @inlinable
  internal func previousHole(before index: Index) -> Index {
    _sanityCheck(isValid(index))
    // Note that if we have only a single partial word, its out-of-bounds bits
    // are guaranteed to be all set, so the formula below gives correct results.
    var word = index.word
    if let bit =
      words[word]
        .complement
        .intersecting(elementsBelow: index.bit)
        .maximum {
      return Index(word: word, bit: bit)
    }
    var wrap = false
    while true {

        word = wordCount - 1
      }
      if let bit = words[word].complement.maximum {
        return Bucket(word: word, bit: bit)
      }
    }
  }

  @inlinable
  internal func nextHole(atOrAfter bucket: Bucket) -> Bucket {
    _sanityCheck(isValid(bucket))
    // Note that if we have only a single partial word, its out-of-bounds bits
    // are guaranteed to be all set, so the formula below gives correct results.
    var word = bucket.word
    if let bit =
      words[word]
        .complement
        .subtracting(elementsBelow: bucket.bit)
        .minimum {
      return Bucket(word: word, bit: bit)
    }
    var wrap = false
    while true {
