Sweden Democrats' Meeting Tool
 All Classes Files Functions Variables Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
sd_tree Class Reference

Public Member Functions

 __construct ()
 add ($key, $data, $parent_key=null)
 get_data ($key)
 set_data ($key, $new_data)
 get_subnodes ($key=null)

Public Attributes

 $root_node
 $node_orphans = array()

Private Member Functions

 add_node (&$intoNode, $key, $data, $parent)
find_node (&$node, $key)

Constructor & Destructor Documentation

sd_tree::__construct ( )

Member Function Documentation

sd_tree::add (   $key,
  $data,
  $parent_key = null 
)

Adds a node to the tree.

Parameters
$keyUnique key of this node.
$dataMixed array to store with this key.
$parent_keyParent key, if any, under which to store this key.
sd_tree::add_node ( $intoNode,
  $key,
  $data,
  $parent 
)
private
& sd_tree::find_node ( $node,
  $key 
)
private

Tries to find a node with a specific key.

Acts as a recursive function of itself.

Parameters
$nodeNode whose subnodes to search.
$keyKey to search for.
Returns
The found node, else false.
sd_tree::get_data (   $key)

Returns the data of a specific key.

Parameters
$keyKey to look for.
Returns
The key's data, else false if the key wasn't found.
sd_tree::get_subnodes (   $key = null)

Returns a list of subnode keys of the root or an existing node.

Parameters
$keyGet the subnodes keys of this key.
Returns
Array of subnode keys, else false if the key doesn't exist.
sd_tree::set_data (   $key,
  $new_data 
)

Sets the data of a key.

Parameters
$keyKey whose data we're replacing.
$new_dataThe new data.

Member Data Documentation

sd_tree::$node_orphans = array()
sd_tree::$root_node

The documentation for this class was generated from the following file: