util 
[ doc home ] [ class tree: util ] [ index: util ] [ all elements ]

Class: IsterTree

Source Location: /IsterTree.php

Class Overview

IsterObject
   |
   --IsterTree

This class represents a directory like (not binary) tree.


Author(s): Ingo Schramm   

Copyright: Copyright (c) 2005 Ister.ORG Ingo Schramm

Methods


Inherited Constants

Inherited Variables

Inherited Methods

Class: IsterObject

IsterObject::IsterObject()
Constructor
IsterObject::abstractMethodError()
Report attempt to call an abstract method.
IsterObject::addLogger()
Add an IsterLogger to process log messages.
IsterObject::deleteLogger()
Delete an already registered IsterLogger.
IsterObject::getLoggerNames()
Fetch the names of all currently registered IsterLoggers.
IsterObject::getMem()
Return maximum amount of memory an application has allocated at this point.
IsterObject::log()
Trigger a log message.
IsterObject::passPHPmessage()
Catch PHP E_WARNING and E_NOTICE messages.
IsterObject::serialize()
Serialize the object.
IsterObject::setLogLocal()
Set logging local for the current object.
IsterObject::setupLogger()
Setup a logger.
IsterObject::triggerError()
Alias for log();
IsterObject::unserialize()
Unserialize the object.
IsterObject::__sleep()
Executed prior to serialize().
IsterObject::__wakeup()
Executed prior to unserialize().

Class Details

This class represents a directory like (not binary) tree.

The path of an element is a string of the form "/<index>/<index>/ ...". Indices starting from 0. For example, the path of second child of first child of third element below root is "/2/0/1".

Important: Some methods of this class make use of eval(). You should never ever pass unchecked user data, neither paths nor values, to these methods. Best practice is to store only numbers as pointers to an element of an external array.


copyright:  Copyright (c) 2005 Ister.ORG Ingo Schramm
author:  Ingo Schramm


[ Top ]


Class Methods


constructor IsterTree

IsterTree IsterTree( )

Constructor

[ Top ]

method add

string add( mixed $val, string $path)

Add an element as a child of $path.

Non existing intermediate nodes will be created with null content. Existing nodes will silently be overwritten. To simply change the value of a node use set(), it's faster. The method returns the path of the new node.


Parameters:

mixed   $val  
string   $path  

[ Top ]

method del

boolean del( string $path)

Delete the element at $path.

Parameters:

string   $path  

[ Top ]

method dump

array dump( )

Return array of path value pairs.

[ Top ]

method get

mixed get( string $path)

Get the content of the node at $path.

Parameters:

string   $path  

[ Top ]

method order

array order( [integer $order = ISTER_TREE_PREORDER])

Get the leaf nodes of the tree as an one dimensional array.

Possible values of $order: ISTER_TREE_PREORDER, ISTER_TREE_POSTORDER, ISTER_TREE_LEVELORDER.


Parameters:

integer   $order  

[ Top ]

method set

boolean set( mixed $val, string $path)

Set the content of the node at path.

Since this method uses eval() you never should set unchecked user input here.


Parameters:

mixed   $val  
string   $path  

[ Top ]

method test

mixed test( string $path)

Test if node exists in tree.

Parameters:

string   $path  

[ Top ]


Documentation generated on Tue, 20 Dec 2005 11:21:22 +0100 by phpDocumentor 1.3.0RC4