Class: RbLovely::SortedHash
Overview
A SortedHash should not be modified during iteration.
This class is only provided if boost is available on the system when the gem is installed as it is built using the Boost Multi-index Containers Library.
Some methods come from the Enumerable module. If you do not find the method you are looking for in this documentation then please look there.
A SortedHash provides hashed unique keys and ordered non-unique values. Values are sorted using “<=>” and keys are tested for equality using “eql?”.
Class Method Summary collapse
-
.[](*content) ⇒ SortedHash
Factory method for creating sorted hash from array.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Retrieve value from hash using key.
-
#[]=(key, value) ⇒ Object
Set the value associated with a key, replacing the existing key’s value.
-
#clear ⇒ Object
Remove all key-value pairs from the hash.
-
#delete(key) ⇒ Object
Delete the value associated with a key.
-
#each(&block) ⇒ Object
Calls block once for each key, passing the key-value pair as parameters.
-
#empty? ⇒ Boolean
Return true if the hash is empty.
-
#first ⇒ Object
Retrieve first key-value pair as determined by value sort order or nil if the hash is empty.
-
#first_key ⇒ Object
Retrieve first key as determined by value sort order or nil if the hash is empty.
-
#first_value ⇒ Array
Retrieve first value as determined by value sort order or nil if the hash is empty.
-
#include?(key) ⇒ Boolean
(also: #has_key?, #key?)
Return true if the key is contained in the hash.
-
#initialize(content = [], compare: nil) ⇒ SortedHash
constructor
A new instance of SortedHash.
-
#last ⇒ Array
Retrieve last key-value pair as determined by value sort order or nil if the hash is empty.
-
#last_key ⇒ Object
Retrieve last key as determined by value sort order or nil if the hash is empty.
-
#last_value ⇒ Object
Retrieve last value as determined by value sort order or nil if the hash is empty.
-
#length ⇒ Number
Gets the number of elements in the hash.
-
#pop ⇒ Array
Remove the last key-value pair in the hash and return it or return nil if the hash is empty.
-
#pop_key ⇒ Object
Remove the last key-value pair in the hash and return the key or return nil if the hash is empty.
-
#pop_value ⇒ Object
Remove the last key-value pair in the hash and return the value or return nil if the hash is empty.
-
#replace(key, value) ⇒ Object
Set the value associated with a key, differs to #[]= in return value.
-
#shift ⇒ Array
Remove the first key-value pair in the hash and return it or return nil if the hash is empty.
-
#shift_key ⇒ Object
Remove the first key-value pair in the hash and return the key or return nil if the hash is empty.
-
#shift_value ⇒ Object
Remove the first key-value pair in the hash and return the value or return nil if the hash is empty.
Constructor Details
#initialize(content = [], compare: nil) ⇒ SortedHash
Returns a new instance of SortedHash.
185 |
# File 'yard.rb', line 185 def initialize content = [], compare: nil ; end |
Class Method Details
.[](*content) ⇒ SortedHash
Factory method for creating sorted hash from array.
194 |
# File 'yard.rb', line 194 def self.[](*content) ; end |
Instance Method Details
#[](key) ⇒ Object
Retrieve value from hash using key.
247 |
# File 'yard.rb', line 247 def [](key) ; end |
#[]=(key, value) ⇒ Object
Set the value associated with a key, replacing the existing key’s value.
203 |
# File 'yard.rb', line 203 def []=(key, value) ; end |
#clear ⇒ Object
Remove all key-value pairs from the hash.
238 |
# File 'yard.rb', line 238 def clear ; end |
#delete(key) ⇒ Object
Delete the value associated with a key.
222 |
# File 'yard.rb', line 222 def delete key ; end |
#each(&block) ⇒ Object
Calls block once for each key, passing the key-value pair as parameters.
230 |
# File 'yard.rb', line 230 def each(&block) ; end |
#empty? ⇒ Boolean
Return true if the hash is empty.
362 |
# File 'yard.rb', line 362 def empty? ; end |
#first ⇒ Object
Retrieve first key-value pair as determined by value sort order or nil if the hash is empty.
260 |
# File 'yard.rb', line 260 def first ; end |
#first_key ⇒ Object
Retrieve first key as determined by value sort order or nil if the hash is empty.
276 |
# File 'yard.rb', line 276 def first_key ; end |
#first_value ⇒ Array
Retrieve first value as determined by value sort order or nil if the hash is empty.
268 |
# File 'yard.rb', line 268 def first_value ; end |
#include?(key) ⇒ Boolean Also known as: has_key?, key?
Return true if the key is contained in the hash.
251 |
# File 'yard.rb', line 251 def include?(key) ; end |
#last ⇒ Array
Retrieve last key-value pair as determined by value sort order or nil if the hash is empty.
284 |
# File 'yard.rb', line 284 def last ; end |
#last_key ⇒ Object
Retrieve last key as determined by value sort order or nil if the hash is empty.
298 |
# File 'yard.rb', line 298 def last_key ; end |
#last_value ⇒ Object
Retrieve last value as determined by value sort order or nil if the hash is empty.
291 |
# File 'yard.rb', line 291 def last_value ; end |
#length ⇒ Number
Gets the number of elements in the hash.
357 |
# File 'yard.rb', line 357 def length ; end |
#pop ⇒ Array
Remove the last key-value pair in the hash and return it or return nil if the hash is empty.
334 |
# File 'yard.rb', line 334 def pop ; end |
#pop_key ⇒ Object
Remove the last key-value pair in the hash and return the key or return nil if the hash is empty.
352 |
# File 'yard.rb', line 352 def pop_key ; end |
#pop_value ⇒ Object
Remove the last key-value pair in the hash and return the value or return nil if the hash is empty.
343 |
# File 'yard.rb', line 343 def pop_value ; end |
#replace(key, value) ⇒ Object
Set the value associated with a key, differs to #[]= in return value.
213 |
# File 'yard.rb', line 213 def replace(key, value) ; end |
#shift ⇒ Array
Remove the first key-value pair in the hash and return it or return nil if the hash is empty.
307 |
# File 'yard.rb', line 307 def shift ; end |
#shift_key ⇒ Object
Remove the first key-value pair in the hash and return the key or return nil if the hash is empty.
325 |
# File 'yard.rb', line 325 def shift_key ; end |
#shift_value ⇒ Object
Remove the first key-value pair in the hash and return the value or return nil if the hash is empty.
316 |
# File 'yard.rb', line 316 def shift_value ; end |