SetaPDF_Core_DataStructure_Tree Abstract data structure class for trees

File: /SetaPDF v2/Core/DataStructure/Tree.php

Class hierarchy

Implements

Summary

Static Properties

$leafNodesPerNode

Leaf nodes per node


Properties

$_document

The document to which the tree depends to

$_isNew

protected boolean SetaPDF_Core_DataStructure_Tree::$_isNew = false

Is this a new tree or should we update an existing one

$_rootDictionary

The dictionary entry in the dictionary of the root object

$_values

protected array SetaPDF_Core_DataStructure_Tree::$_values = array()

A cache for resolved entries

The index is the key while the value is an array of both key and value object.


Methods

__construct()

The constructor.

Parameters
$rootDictionary : SetaPDF_Core_Type_Dictionary
 
$document : SetaPDF_Core_Document
 

_findLastLeafNode()

Finds the last leaf node.

Parameters
$node : SetaPDF_Core_Type_Dictionary
 
$intermediateNodes : array
 

_findLeaveNodeByKey()

protected SetaPDF_Core_DataStructure_Tree::_findLeaveNodeByKey (
SetaPDF_Core_Type_Dictionary $node, int $key [, bool $exactMatch = true [, array &$intermediateNodes = array ( ) ]]
): bool|SetaPDF_Core_Type_Dictionary

Find a appropriate leaf node by a key.

If $lowest is set to false the method will search for a leaf node where the key fits between its limit values. If $lowest is set to true the method will return the first leaf node it finds which left limit is bigger than the key.

Parameters
$node : SetaPDF_Core_Type_Dictionary
 
$key : int
 
$exactMatch : bool
 
$intermediateNodes : array
 

_get()

protected SetaPDF_Core_DataStructure_Tree::_get (
SetaPDF_Core_Type_Dictionary $node, string $key
): array|false

Gets a key value pair by a root node and a key.

Parameters
$node : SetaPDF_Core_Type_Dictionary
 
$key : string
 

_getBlankLeafNodeObject()

Helper method to create a blank leaf node

Parameters
$intermediate : boolean
 

_getEntriesKeyName()

abstract protected SetaPDF_Core_DataStructure_Tree::_getEntriesKeyName (
void
): string

Get the entries key name by tree implementation.

_getKeyClassName()

abstract protected SetaPDF_Core_DataStructure_Tree::_getKeyClassName (
void
): string

Get the key class name by tree implementation.

_getKeyInstanceName()

Get the key instance name by tree implementation.

_getSortType()

abstract protected SetaPDF_Core_DataStructure_Tree::_getSortType (
void
): integer

Get the sort type for the specific tree implementation.

See

add()

public SetaPDF_Core_DataStructure_Tree::add (
int|string $key, SetaPDF_Core_Type_AbstractType $value
): void

Add a keyed value to the tree.

For name trees: Make sure you pass the name in PDFDocEncoding or UTF-16BE including BOM.

Parameters
$key : int|string

Depends on the implementation

$value : SetaPDF_Core_Type_AbstractType
 
Exceptions

Throws SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException

See

cleanUp()

Release objects to free memory and cycled references

After calling this method the instance of this object is unusable!

get()

public SetaPDF_Core_DataStructure_Tree::get (
string $key [, string $className = null ]
): SetaPDF_Core_Type_AbstractType|false|mixed

Get an object by a key.

Parameters
$key : string
 
$className : string
 

getAll()

public SetaPDF_Core_DataStructure_Tree::getAll (
[ bool $keysOnly = false [, null|string $className = null ]]
): array

Get all keyed objects.

Parameters
$keysOnly : bool
 
$className : null|string
 

merge()

public SetaPDF_Core_DataStructure_Tree::merge (
SetaPDF_Core_DataStructure_Tree $tree [, null|callback $alreadyExistsCallback = null ]
): array

Merges another tree into this tree.

As all items have to be unique this method will call a callback function given in $alreadyExistsCallback if an item already exists.

Parameters
$tree : SetaPDF_Core_DataStructure_Tree
 
$alreadyExistsCallback : null|callback

Will be called if a item already exists.
This method can take control over the renaming of the item. The method will be called as long as it will not throw an exception of SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException.
The parameter of the callback function are: The key value and an incremental number of renaming attempts.

Return Values

An array of renamed items

Exceptions

Throws SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException

remove()

public SetaPDF_Core_DataStructure_Tree::remove (
string $key
): boolean

Remove a key from the tree

Parameters
$key : string
 

toPhp()

public SetaPDF_Core_DataStructure_Tree::toPhp (
void
): array

Returns an array with named keys and name values

See