Tree: ezcTreeMemory
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTreeMemory
|
ezcTreeMemory is an implementation of a tree backend that operates on an in-memory tree structure. Meta-information is kept in objects of the ezcTreeMemoryNode class. [
source]
See
ezcTree for examples on how to operate on the tree.
Parents
ezcTree
|
--ezcTreeMemory
Properties
|
string |
read/write
|
$nodeClassName
Which class is used as tree node - this class *must* inherit the ezcTreeNode class. |
|
ezcTreeXmlDataStore |
read
|
$store
The data store that is used for retrieving/storing data. |
Inherited Member Variables
From
ezcTree:
Method Summary
|
protected ezcTreeMemory |
__construct(
$store )
Constructs a new ezcTreeMemory object. |
|
public void |
addChild(
$parentId, $childNode )
Adds the node $childNode as child of the node with ID $parentId |
|
public static ezcTreeMemory |
create(
$store )
A factory method that creates a new empty tree using the data store $store. |
|
public void |
delete(
$nodeId )
Deletes the node with ID $nodeId from the tree, including all its children |
|
public ezcTreeNodeList |
fetchChildren(
$nodeId )
Returns all the children of the node with ID $nodeId. |
|
public ezcTreeNode |
fetchNodeById(
$nodeId )
Returns the node identified by the ID $nodeId. |
|
public ezcTreeNode |
fetchParent(
$nodeId )
Returns the parent node of the node with ID $nodeId. |
|
public ezcTreeNodeList |
fetchPath(
$nodeId )
Returns all the nodes in the path from the root node to the node with ID $nodeId, including those two nodes. |
|
public ezcTreeNodeList |
fetchSubtree(
$nodeId )
Alias for fetchSubtreeDepthFirst(). |
|
public ezcTreeNodeList |
fetchSubtreeBreadthFirst(
$nodeId )
Returns the node with ID $nodeId and all its children, sorted according to the Breadth-first sorting algorithm. |
|
public ezcTreeNodeList |
fetchSubtreeDepthFirst(
$nodeId )
Returns the node with ID $nodeId and all its children, sorted accoring to the Depthth-first sorting algorithm. |
|
public void |
fixateTransaction(
)
Fixates the transaction. |
|
protected integer |
generateNodeID(
)
This method generates the next node ID. |
|
public int |
getChildCount(
$nodeId )
Returns the number of direct children of the node with ID $nodeId. |
|
public int |
getChildCountRecursive(
$nodeId )
Returns the number of children of the node with ID $nodeId, recursively |
|
public int |
getPathLength(
$nodeId )
Returns the distance from the root node to the node with ID $nodeId |
|
public ezcTreeNode |
getRootNode(
)
Returns the root node |
|
public bool |
hasChildNodes(
$nodeId )
Returns whether the node with ID $nodeId has children |
|
public bool |
isChildOf(
$childId, $parentId )
Returns whether the node with ID $childId is a direct child of the node with ID $parentId |
|
public bool |
isDescendantOf(
$childId, $parentId )
Returns whether the node with ID $childId is a direct or indirect child of the node with ID $parentId |
|
public bool |
isSiblingOf(
$child1Id, $child2Id )
Returns whether the nodes with IDs $child1Id and $child2Id are siblings (ie, the share the same parent) |
|
public void |
move(
$nodeId, $targetParentId )
Moves the node with ID $nodeId as child to the node with ID $targetParentId |
|
public bool |
nodeExists(
$nodeId )
Returns whether the node with ID $nodeId exists. |
|
public void |
setRootNode(
$node )
Sets a new node as root node, this wipes also out the whole tree |
Inherited Methods
From
ezcTree :
Methods
__construct
Constructs a new ezcTreeMemory object.
The store that is used for data storage should be passed as the $store argument.
Parameters
addChild
void addChild(
string
$parentId,
ezcTreeNode
$childNode )
Adds the node $childNode as child of the node with ID $parentId
Parameters
| Name |
Type |
Description |
$parentId |
string |
|
$childNode |
ezcTreeNode |
|
Redefinition of
| Method |
Description |
ezcTree::addChild() |
Adds the node $childNode as child of the node with ID $parentId. |
create
A factory method that creates a new empty tree using the data store $store.
Parameters
delete
void delete(
string
$nodeId )
Deletes the node with ID $nodeId from the tree, including all its children
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
| Method |
Description |
ezcTree::delete() |
Deletes the node with ID $nodeId from the tree, including all its children. |
fetchChildren
Returns all the children of the node with ID $nodeId.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
fetchNodeById
Returns the node identified by the ID $nodeId.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Throws
| Class | Description |
ezcTreeInvalidIdException |
if there is no node with ID $nodeId |
Redefinition of
fetchParent
Returns the parent node of the node with ID $nodeId.
This method returns null if there is no parent node.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
fetchPath
Returns all the nodes in the path from the root node to the node with ID $nodeId, including those two nodes.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
| Method |
Description |
ezcTree::fetchPath() |
Returns all the nodes in the path from the root node to the node with ID $nodeId, including those two nodes. |
fetchSubtree
Alias for fetchSubtreeDepthFirst().
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
fetchSubtreeBreadthFirst
Returns the node with ID $nodeId and all its children, sorted according to the
Breadth-first sorting algorithm.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
fetchSubtreeDepthFirst
Returns the node with ID $nodeId and all its children, sorted accoring to the
Depthth-first sorting algorithm.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
fixateTransaction
void fixateTransaction(
)
Fixates the transaction.
generateNodeID
integer generateNodeID(
)
This method generates the next node ID.
Redefinition of
getChildCount
int getChildCount(
string
$nodeId )
Returns the number of direct children of the node with ID $nodeId.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
getChildCountRecursive
int getChildCountRecursive(
string
$nodeId )
Returns the number of children of the node with ID $nodeId, recursively
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
getPathLength
int getPathLength(
string
$nodeId )
Returns the distance from the root node to the node with ID $nodeId
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
getRootNode
Returns the root node
This methods returns null if there is no root node.
Redefinition of
hasChildNodes
bool hasChildNodes(
string
$nodeId )
Returns whether the node with ID $nodeId has children
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
isChildOf
bool isChildOf(
string
$childId, string
$parentId )
Returns whether the node with ID $childId is a direct child of the node with ID $parentId
Parameters
| Name |
Type |
Description |
$childId |
string |
|
$parentId |
string |
|
Redefinition of
| Method |
Description |
ezcTree::isChildOf() |
Returns whether the node with ID $childId is a direct child of the node with ID $parentId. |
isDescendantOf
bool isDescendantOf(
string
$childId, string
$parentId )
Returns whether the node with ID $childId is a direct or indirect child of the node with ID $parentId
Parameters
| Name |
Type |
Description |
$childId |
string |
|
$parentId |
string |
|
Redefinition of
| Method |
Description |
ezcTree::isDescendantOf() |
Returns whether the node with ID $childId is a direct or indirect child of the node with ID $parentId. |
isSiblingOf
bool isSiblingOf(
string
$child1Id, string
$child2Id )
Returns whether the nodes with IDs $child1Id and $child2Id are siblings (ie, the share the same parent)
Parameters
| Name |
Type |
Description |
$child1Id |
string |
|
$child2Id |
string |
|
Redefinition of
| Method |
Description |
ezcTree::isSiblingOf() |
Returns whether the nodes with IDs $child1Id and $child2Id are siblings (ie, they share the same parent). |
move
void move(
string
$nodeId, string
$targetParentId )
Moves the node with ID $nodeId as child to the node with ID $targetParentId
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
$targetParentId |
string |
|
Redefinition of
| Method |
Description |
ezcTree::move() |
Moves the node with ID $nodeId as child to the node with ID $targetParentId. |
nodeExists
bool nodeExists(
string
$nodeId )
Returns whether the node with ID $nodeId exists.
Parameters
| Name |
Type |
Description |
$nodeId |
string |
|
Redefinition of
setRootNode
Sets a new node as root node, this wipes also out the whole tree
Parameters
Redefinition of
Last updated: Mon, 27 Jul 2009