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

View File

@ -1,46 +1,40 @@
<?php
namespace Moserware\Skills;
require_once(dirname(__FILE__) . "/HashMap.php");
class RatingContainer
{
private $_playerHashToRating = array();
private $_playerHashToPlayer = array();
private $_playerToRating;
public function __construct()
{
$this->_playerToRating = new \HashMap();
}
public function getRating($player)
{
return $this->_playerHashToRating[self::getHash($player)];
return $this->_playerToRating->getValue($player);
}
public function setRating($player, $rating)
{
$hash = self::getHash($player);
$this->_playerHashToPlayer[$hash] = $player;
$this->_playerHashToRating[$hash] = $rating;
return $this;
return $this->_playerToRating->setValue($player, $rating);
}
public function getAllPlayers()
{
return \array_values($this->_playerHashToPlayer);
return $this->_playerToRating->getAllKeys();
}
public function getAllRatings()
{
return \array_values($this->_playerHashToRating);
return $this->_playerToRating->getAllValues();
}
public function count()
{
return \count($this->_playerHashToPlayer);
}
private static function getHash($player)
{
if(\is_object($player))
{
return \spl_object_hash($player);
}
return $player;
}
return \count($this->_playerToRating->count());
}
}
?>