Module: RangeList::Map::SortedMap
- Included in:
- TreeMap
- Defined in:
- lib/range_list/map/sorted_map.rb
Overview
A Map that provides a ordering on its keys.
Instance Method Summary collapse
-
#ceiling_entry(key) ⇒ Object
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
-
#each(&block) ⇒ Object
Support iteration.
-
#floor_entry(key) ⇒ Object
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
-
#get(key) ⇒ Object
Returns the value to which the specified key is mapped, or nil if this map contains no mapping for the key.
-
#higher_entry(key) ⇒ Object
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
-
#lower_entry(key) ⇒ Object
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
-
#put(key, value) ⇒ Object
Associates the specified value with the specified key in this map.
-
#remove(key) ⇒ Object
Removes the mapping for a key from this map if it is present.
-
#sub_map(from_key, to_key) ⇒ Object
Returns a view of the portion of this map whose keys range from from_key, inclusive, to to_key, exclusive.
Instance Method Details
#ceiling_entry(key) ⇒ Object
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
31 32 33 |
# File 'lib/range_list/map/sorted_map.rb', line 31 def ceiling_entry(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#each(&block) ⇒ Object
Support iteration.
53 54 55 |
# File 'lib/range_list/map/sorted_map.rb', line 53 def each(&block) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#floor_entry(key) ⇒ Object
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
25 26 27 |
# File 'lib/range_list/map/sorted_map.rb', line 25 def floor_entry(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#get(key) ⇒ Object
Returns the value to which the specified key is mapped, or nil if this map contains no mapping for the key.
8 9 10 |
# File 'lib/range_list/map/sorted_map.rb', line 8 def get(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#higher_entry(key) ⇒ Object
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
43 44 45 |
# File 'lib/range_list/map/sorted_map.rb', line 43 def higher_entry(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#lower_entry(key) ⇒ Object
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
37 38 39 |
# File 'lib/range_list/map/sorted_map.rb', line 37 def lower_entry(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#put(key, value) ⇒ Object
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
14 15 16 |
# File 'lib/range_list/map/sorted_map.rb', line 14 def put(key, value) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#remove(key) ⇒ Object
Removes the mapping for a key from this map if it is present.
19 20 21 |
# File 'lib/range_list/map/sorted_map.rb', line 19 def remove(key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |
#sub_map(from_key, to_key) ⇒ Object
Returns a view of the portion of this map whose keys range from from_key, inclusive, to to_key, exclusive.
48 49 50 |
# File 'lib/range_list/map/sorted_map.rb', line 48 def sub_map(from_key, to_key) raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'" end |