A number tree: a sorted map from integer 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.7).")]
public sealed class PdfNumberTree : IEnumerable<KeyValuePair<int, CosObject>>, IEnumerable
ISO 32000-2 §7.9.7, Table 37 (PDF 1.3). Like PdfNameTree with integer keys in ascending numerical order, held in
Nums arrays. Keys are 32-bit integers. Lookups are guided by each node's Limits; TryGetFloor(Int32, out Int32, out CosObject) and
enumeration read the whole tree. Values come back resolved one level.
Damage is read leniently, as for PdfNameTree: each deviation is reported once per node when it is first read (in strict mode the lookup or enumeration that meets it throws), lookups fall back to an index of every key built once, and a key that appears twice resolves to its first occurrence in tree order. A key written as a real with an integral value is used as that integer, with a diagnostic; any other non-integer key is skipped.
Editable in place (issue #146): Set(Int32, CosObject) inserts or replaces a key and Remove(Int32) removes one, changing only the
nodes on the way from the root to the key's leaf and keeping every Limits entry correct; see
CreateNumberTree(IEnumerable<KeyValuePair<Int32, 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(Int32)Determines whether the tree holds key.GetEnumerator()Returns the keys and values in tree order (ascending in a well-formed tree), each key once.Remove(Int32)Removes key and its value.Set(Int32, CosObject)Inserts key with value, or replaces the value of the key the tree already holds.TryGetFloor(Int32, out Int32, out CosObject)Finds the greatest key that is not greater than key, and its value.TryGetValue(Int32, out CosObject)Looks up key.