kernel/bootstrap/hash.rb
# Grows or shrinks the hash storage and redistributes the entries
# among the new bins if the entry density is outside the max/min
# thresholds. Any Iterator instance will be invalid after a call
# to redistribute. If +rehash+ is true, recalculate the key_hash
# for each key.
Grows or shrinks the hash storage and redistributes the entries
among the new bins if the entry density is outside the max/min
thresholds. Any Iterator instance will be invalid after a call
to redistribute. If +rehash+ is true, recalculate the key_hash
for each key.
Grows or shrinks the hash storage and redistributes the entries among the new bins if the entry density is outside the max / min thresholds . Any Iterator instance will be invalid after a call to redistribute . If + rehash + is true recalculate the key_hash for each key .
def redistribute(rehash = true)
    if @count >= MAX_DENSITY * @records
      new_size = @records * 2
    elsif @count < MIN_DENSITY * @records and @records > MIN_SIZE
      new_size = @records / 2
    else
      return unless rehash
      new_size = @records
    end
    i = to_iter
    @records = new_size
    @bins = Tuple.new @records
    while entry = i.next
      while entry
        nxt = entry.next
        entry.key_hash = entry.key.hash if rehash
        bin = entry_bin entry.key_hash
        if head = @bins[bin]
          entry.next = head
        else
          entry.next = nil
        end
        @bins[bin] = entry
        entry = nxt
      end
    end
    self
  end
def redistribute ( rehash = true ) if @count >= MAX_DENSITY * @records new_size = @records * 2 elsif @count < MIN_DENSITY * @records and @records > MIN_SIZE new_size = @records / 2 else return unless rehash new_size = @records end i = to_iter @records = new_size @bins = Tuple . new @records while entry = i . next while entry nxt = entry . next entry . key_hash = entry . key . hash if rehash bin = entry_bin entry . key_hash if head = @bins [ bin ] entry . next = head else entry . next = nil end @bins [ bin ] = entry entry = nxt end end self end
Grows or shrinks the hash storage and redistributes the entries
among the new bins if the entry density is outside the max/min
thresholds.
Grows or shrinks the hash storage and redistributes the entries among the new bins if the entry density is outside the max / min thresholds .
rehash
<not_specific>