public function add($o) { if (!is_a($o, 'IComparable')) { throw new IllegalArgumentException('Argument must implement IComparable interface'); } if ($this->isEmpty($o)) { return parent::add($o); } return parent::add($o); }
/** * Main program. * * @param array $args Command-line arguments. * @return integer Zero on success; non-zero on failure. */ public static function main($args) { printf("SetAsBitVector main program.\n"); $status = 0; $s1 = new SetAsBitVector(57); $s2 = new SetAsBitVector(57); $s3 = new SetAsBitVector(57); AbstractSet::test($s1, $s2, $s3); return $status; }
/** * Destructor. */ public function __destruct() { parent::__destruct(); }
public function __construct() { parent::__construct(); }
/** * Destructor. */ public function __destruct() { $this->partition = NULL; $this->parent = NULL; parent::__destruct(); }
/** * Constructs a Set object of the specified type, * optionally with the specified data * * @param string $setType * @param array $data */ public function __construct($setType, array $data = []) { $this->setType = $setType; parent::__construct($data); }
printf("%s\n", str($s2)); printf("%s\n", str($s3)); printf("%s\n", str($s1->union($s2))); # union printf("%s\n", str($s1->intersection($s3))); # intersection printf("%s\n", str($s1->difference($s3))); # difference printf("Using foreach\n"); foreach ($s3 as $obj) { printf("%s\n", str($obj)); } printf("Using reduce\n"); $s3->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), ''); } /** * Main program. * * @param array $args Command-line arguments. * @return integer Zero on success; non-zero on failure. */ public static function main($args) { printf("AbstractSet main program.\n"); $status = 0; return $status; } } if (realpath($argv[0]) == realpath(__FILE__)) { exit(AbstractSet::main(array_slice($argv, 1))); }