Start of factor graph port. Things don't work yet, but a lot of syntax updates towards PHP

This commit is contained in:
Jeff Moser
2010-09-18 11:11:44 -04:00
parent 4a76cc34cc
commit e434696b44
25 changed files with 1637 additions and 20 deletions

46
HashMap.php Normal file
View File

@ -0,0 +1,46 @@
<?php
class HashMap
{
private $_hashToValue = array();
private $_hashToKey = array();
public function getValue($key)
{
return $this->_hashToValue[self::getHash($key)];
}
public function setValue($key, $value)
{
$hash = self::getHash($key);
$this->_hashToKey[$hash] = $key;
$this->_hashToValue[$hash] = $value;
return $this;
}
public function getAllKeys()
{
return \array_values($this->_hashToKey);
}
public function getAllValues()
{
return \array_values($this->_hashToValue);
}
public function count()
{
return \count($this->_hashToKey);
}
private static function getHash($key)
{
if(\is_object($key))
{
return \spl_object_hash($key);
}
return $key;
}
}
?>