More debugging and realizing how PHP does references

This commit is contained in:
Jeff Moser
2010-09-25 15:46:23 -04:00
parent e8d444e7da
commit 086d94865f
21 changed files with 77 additions and 72 deletions

View File

@ -36,12 +36,12 @@ abstract class Factor
return count($this->_messages);
}
protected function getVariables()
protected function &getVariables()
{
return $this->_variables;
}
protected function getMessages()
protected function &getMessages()
{
return $this->_messages;
}
@ -77,11 +77,11 @@ abstract class Factor
return $this->sendMessageVariable($message, $variable);
}
protected abstract function sendMessageVariable(Message $message, Variable $variable);
protected abstract function sendMessageVariable(Message &$message, Variable &$variable);
public abstract function createVariableToMessageBinding(Variable $variable);
public abstract function createVariableToMessageBinding(Variable &$variable);
protected function createVariableToMessageBindingWithMessage(Variable $variable, Variable $message)
protected function createVariableToMessageBindingWithMessage(Variable &$variable, Variable &$message)
{
$index = count($this->_messages);
$this->_messages[] = $message;

View File

@ -5,14 +5,14 @@ class FactorGraph
{
private $_variableFactory;
public function getVariableFactory()
public function &getVariableFactory()
{
return $this->_variableFactory;
}
public function setVariableFactory($factory)
public function setVariableFactory(&$factory)
{
$this->_variableFactory = $factory;
$this->_variableFactory = &$factory;
}
}
?>

View File

@ -1,6 +1,7 @@
<?php
namespace Moserware\Skills\FactorGraphs;
require_once(dirname(__FILE__) . "/FactorGraph.php");
require_once(dirname(__FILE__) . "/Schedule.php");
abstract class FactorGraphLayer
@ -10,44 +11,44 @@ abstract class FactorGraphLayer
private $_inputVariablesGroups = array();
private $_parentFactorGraph;
protected function __construct($parentGraph)
protected function __construct(FactorGraph &$parentGraph)
{
$this->_parentFactorGraph = $parentGraph;
$this->_parentFactorGraph = &$parentGraph;
}
protected function getInputVariablesGroups()
protected function &getInputVariablesGroups()
{
return $this->_inputVariablesGroups;
}
// HACK
public function getParentFactorGraph()
public function &getParentFactorGraph()
{
return $this->_parentFactorGraph;
}
public function getOutputVariablesGroups()
public function &getOutputVariablesGroups()
{
return $this->_outputVariablesGroups;
}
public function getLocalFactors()
public function &getLocalFactors()
{
return $this->_localFactors;
}
public function setInputVariablesGroups($value)
public function &setInputVariablesGroups(&$value)
{
$this->_inputVariablesGroups = $value;
}
protected function scheduleSequence($itemsToSequence)
protected function scheduleSequence(&$itemsToSequence)
{
return new ScheduleSequence("TODO", $itemsToSequence);
}
protected function addLayerFactor($factor)
protected function addLayerFactor(&$factor)
{
$this->_localFactors[] = $factor;
}

View File

@ -49,7 +49,7 @@ class FactorList
return count($this->_list);
}
public function addFactor(Factor $factor)
public function addFactor(Factor &$factor)
{
$this->_list[] = $factor;
return $factor;

View File

@ -14,12 +14,12 @@ class Variable
$this->resetToPrior();
}
public function getValue()
public function &getValue()
{
return $this->_value;
}
public function setValue($value)
public function setValue(&$value)
{
$this->_value = $value;
}