Method: Puppet::Graph::RbTreeMap#delete

Defined in:
lib/puppet/graph/rb_tree_map.rb

#delete(key) ⇒ Object

Deletes the item and key if it’s found, 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("MA") #=> "Massachusetts"


123
124
125
126
127
128
129
130
131
132
133
# File 'lib/puppet/graph/rb_tree_map.rb', line 123

def delete(key)
  result = nil
  if @root
    return unless has_key? key

    @root, result = delete_recursive(@root, key)
    @root.color = :black if @root
    @size -= 1
  end
  result
end