Files
YuCheng Hu 8fe9b866f2 添加到 trunk
+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@353 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
2010-06-17 18:33:28 +00:00

34 lines
648 B
PHP

<?php
//Todo: find a decent set implementation for php
class Set{
public function __construct($arr){
$this->store = array();
foreach($arr as $el){
$this->store[$el] = $el;
}
}
public function add($value){
$this->store[$value] = $value;
}
public function member($value){
return array_key_exists($value, $this->store);
}
public function union($otherSet){
return new Set(array_merge($this->store, $otherSet->store));
}
public function unionInPlace($otherSet){
$this->store = $this->union($otherSet)->store;
}
public function remove($value){
unset($this->store[$value]);
}
}
?>