PTNumberTree
@interface PTNumberTree : NSObject
A NumberTree is a common data structure in PDF. See section 3.8.6 ‘Number Trees’ in PDF Reference Manual for more details.
A number tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NumberTrees allow efficient storage of very large association collections (number/Obj* maps). A NumberTree can have many more entries than a SDF/Cos dictionary can.
Sample code:
PDFDoc doc("../Data/test.pdf");
NumberTree labels(doc.GetRoot().Get("PageLabels").Value());
if (labels.IsValid()) {
// Traversing the NumberTree
for (NumberTreeIterator i = labels.GetIterator(); i.HasNext(); i.Next())
cout << "Key: " << i.Key().GetNumber() << endl;
}
-
Declaration
Objective-C
- (BOOL)IsValid;Swift
func isValid() -> BoolReturn Value
whether this is a valid (non-null) NumberTree. If the function returns false the underlying SDF/Cos object is null and the NumberTree object should be treated as null as well.
-
Undocumented
Declaration
Objective-C
- (PTDictIterator*)GetNumberIteratorWithKey: (int)key;Swift
func getNumberIterator(withKey key: Int32) -> PTDictIterator! -
Search for the specified key in the NumberTree.
Sample code: NumberTreeIterator i = dests.Find(5); if (i.HasNext()) { cout << “Key: ” << i.GetKey()->GetNumber() << endl; cout << “Value: ” << i.GetValue()->GetType() << endl; }
Declaration
Objective-C
- (PTDictIterator *)GetIterator;Swift
func getIterator() -> PTDictIterator!Parameters
keythe number representing the key to be found.
Return Value
If the key is present the function returns a NumberTreeIterator the points to the given Key/Value pair. If the key is not found the function returns End() (a non-valid) iterator.
-
Puts a new entry in the name tree. If an entry with this number is already in the tree, it is replaced.
Declaration
Objective-C
- (void)Put:(int)key value:(PTObj *)value;Swift
func put(_ key: Int32, value: PTObj!)Parameters
keyA number representing the key of the new entry.
valuethe value associated with the key. It can be any SDF::Obj.
-
Removes the specified object from the tree. Does nothing if no object with that number exists.
Declaration
Objective-C
- (void)EraseNumberTreeEntryWithKey:(int)key;Swift
func eraseNumberTreeEntry(withKey key: Int32)Parameters
keyA number representing the key of the entry to be removed.
-
Removes the NumberTree entry pointed by the iterator.
Declaration
Objective-C
- (void)EraseNumberTreeEntryWithPos:(PTDictIterator *)pos;Swift
func eraseNumberTreeEntry(withPos pos: PTDictIterator!)Parameters
posdictionary iterator object that points to the NumberTree entry to be removed
PTNumberTree Class Reference