예제 #1
0
 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);
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * Destructor.
  */
 public function __destruct()
 {
     parent::__destruct();
 }
예제 #4
0
 public function __construct()
 {
     parent::__construct();
 }
예제 #5
0
 /**
  * Destructor.
  */
 public function __destruct()
 {
     $this->partition = NULL;
     $this->parent = NULL;
     parent::__destruct();
 }
예제 #6
0
파일: Set.php 프로젝트: ramsey/collection
 /**
  * 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);
 }
예제 #7
0
        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)));
}