module HexaPDF:: Utils:: SortedTreeNode
Provides the convenience methods that are used for name trees and number trees.
The provided methods require two methods defined in the including class so that they work correctly:
- leaf_node_container_name
-
Defines the dictionary entry name that contains the leaf node entries.
For example, for name trees this would be :Names.
- key_type
-
Defines the class that is used for the keys in the tree.
The class defined this way is used for making sure that only valid keys are used.
For example, for name trees this would be String.
Note: Like with HexaPDF::Dictionary
, the keys are assumed to always be direct objects!
Public Instance Methods
Adds a new tree entry (key-data pair) to the sorted tree and returns true
if it was successfully added.
If the option overwrite
is true
, an existing entry is overwritten. Otherwise an error is raised.
This method has to be invoked on the root node of the tree!
Deletes the entry specified by the key
from the tree and returns the data. If the tree doesn’t contain the key, nil
is returned.
This method has to be invoked on the root node of the tree!
Calls the given block once for each entry (key-data pair) of the sorted tree.
Finds and returns the associated entry for the key, or returns nil
if no such key is found.
Tree nodes must always be indirect.
Note: There is no requirement that the root node of a tree must be indirect. However, making it indirect simplifies the implementation and is not against the spec.