Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/sorted_containers/core_extensions.rb
Overview
Array class is being extended to include methods for converting an Array to a SortedSet, SortedHash, and SortedArray.
Instance Method Summary collapse
-
#to_sorted_a(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedArray
Converts the array to a SortedArray.
-
#to_sorted_h(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedHash
Converts the array to a SortedHash.
-
#to_sorted_set(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedSet
Converts the array to a SortedSet.
Instance Method Details
#to_sorted_a(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedArray
Converts the array to a SortedArray.
27 28 29 |
# File 'lib/sorted_containers/core_extensions.rb', line 27 def to_sorted_a(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) SortedContainers::SortedArray.new(self, load_factor: load_factor) end |
#to_sorted_h(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedHash
Converts the array to a SortedHash.
18 19 20 21 |
# File 'lib/sorted_containers/core_extensions.rb', line 18 def to_sorted_h(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) hash = SortedContainers::SortedHash.new(load_factor: load_factor) hash.merge!(self) end |
#to_sorted_set(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) ⇒ SortedContainers::SortedSet
Converts the array to a SortedSet.
10 11 12 |
# File 'lib/sorted_containers/core_extensions.rb', line 10 def to_sorted_set(load_factor: SortedContainers::SortedArray::DEFAULT_LOAD_FACTOR) SortedContainers::SortedSet.new(self, load_factor: load_factor) end |