A name tree: a sorted map from string keys to objects, spread over a tree of node dictionaries. A live view.
[SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "The name is the ISO 32000-2 term (§7.9.6).")]
public sealed class PdfNameTree : IEnumerable<KeyValuePair<CosString, CosObject>>, IEnumerable
ISO 32000-2 §7.9.6, Table 36 (PDF 1.2). Keys are strings compared byte by byte (Annex J.3.3): (a) and the UTF-16BE key
<FEFF0061> are different keys even though both read as "a". The tree is read lazily: a lookup loads one node per
level, guided by each node's Limits; enumeration walks the whole tree in order. Values come back resolved one level (a
value stored as an indirect reference returns the object it refers to).
Damaged trees are read leniently. A node without usable Limits, a key outside its node's Limits, keys out of order,
a key that appears twice, a node reached twice (a cycle), a tree deeper than 64 levels, an odd-length Names array, and a key
that is not a string are each reported once per node as a diagnostic; lookups then fall back to an index of every key, built once
by walking the whole tree and kept until a node of the tree changes. When a key appears twice, the first occurrence in tree order
is the one both lookups and enumeration return once a walk has met the damage (until then a lookup follows the Limits it finds). Diagnostics are reported when the damage is first read, so in strict mode the
lookup or enumeration that meets it throws a DiagnosticException, not Open(String).
Editable in place (issue #146): Set(CosString, CosObject) inserts or replaces a key and Remove(CosString) removes one, changing only the
nodes on the way from the root to the key's leaf and keeping every Limits entry correct; see
CreateNameTree(IEnumerable<KeyValuePair<CosString, CosObject>>) for building a new tree. A damaged tree is rebuilt balanced on its first edit.
Safe for concurrent reads while nobody changes the document; edits are single-threaded, like every change to a document.
kind:method, kind:property, kind:ctor. Press Esc to clear.RootGets the root node dictionary.RootReferenceGets the indirect reference to the root node, or null when the root is a direct dictionary.ContainsKey(CosString)Determines whether the tree holds the key with the same bytes as key.GetEnumerator()Returns the keys and values in tree order (ascending byte order in a well-formed tree), each key once.Remove(CosString)Removes key and its value.Set(CosString, CosObject)Inserts key with value, or replaces the value of the key the tree already holds.TryGetValue(CosString, out CosObject)Looks up the key with the same bytes as key.TryGetValue(ReadOnlySpan<Byte>, out CosObject)Looks up the key whose bytes are key.TryGetValue(String, out CosObject)Looks up the key that reads as the text key.