Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/sorted_containers/core_extensions.rb

Overview

Hash class is being extended to include a method for converting a Hash to a SortedHash.

Instance Method Summary collapse

Instance Method Details

#to_sorted_h(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedHash

Converts the hash to a SortedHash.

Parameters:

  • load_factor (Integer) (defaults to: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR)

    The load factor for the SortedHash.

Returns:



39
40
41
42
43
# File 'lib/sorted_containers/core_extensions.rb', line 39

def to_sorted_h(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR)
  hash = SortedContainers::SortedHash.new(load_factor: load_factor)
  hash.merge!(self)
  hash
end