module HexaPDF::Utils::SortedTreeNode
def delete_entry(key)
doesn't contain the key, +nil+ is returned.
Deletes the entry specified by the +key+ from the tree and returns the data. If the tree
def delete_entry(key) if key?(:Limits) raise HexaPDF::Error, "Deleting a tree entry is only allowed via the root node" end stack = [self] path_to_key(self, key, stack) container_name = leaf_node_container_name return unless stack.last[container_name] index = find_in_leaf_node(stack.last[container_name], key) return unless stack.last[container_name][index] == key stack.last[container_name].delete_at(index) # deletes key value = stack.last[container_name].delete_at(index) stack.last[:Limits] = stack.last[container_name].values_at(0, -2) if stack.last[:Limits] stack.reverse_each.inject do |nested_node, node| if (!nested_node[container_name] || nested_node[container_name].empty?) && (!nested_node[:Kids] || nested_node[:Kids].empty?) node[:Kids].delete(nested_node) document.delete(nested_node) end if !node[:Kids].empty? && node[:Limits] node[:Limits][0] = node[:Kids][0][:Limits][0] node[:Limits][1] = node[:Kids][-1][:Limits][1] end node end value end