Method: Containers::RubyRBTreeMap#delete_max

Defined in:
lib/containers/rb_tree_map.rb

#delete_maxObject

Deletes the item with the largest key and returns the item. Returns nil if key is not present.

Complexity: O(log n)

map = Containers::TreeMap.new
map.push("MA", "Massachusetts")
map.push("GA", "Georgia")
map.delete_max #=> "Georgia"
map.size #=> 1


173
174
175
176
177
178
179
180
# File 'lib/containers/rb_tree_map.rb', line 173

def delete_max
  result = nil
  if @root
    @root, result = delete_max_recursive(@root)
    @root.color = :black if @root
  end
  result
end