Example #1
0
 /**
  * Tests whether this set is a subset of the specified set.
  * It is assumed that the specified set is an instance of
  * the <code>SetAsBitVector</code> class.
  *
  * @param object ISet $set The set to compare with this set.
  * @return boolean True if the this set is a subset of the specified set;
  * false otherwise.
  */
 public function isSubset(ISet $set)
 {
     if ($this->getClass() != $set->getClass()) {
         throw new TypeError();
     }
     if ($this->universeSize != $set->universeSize) {
         throw new ArgumentError();
     }
     for ($i = 0; $i < $this->vector->length(); ++$i) {
         if (($this->vector[$i] & ~$set->vector[$i]) != 0) {
             return false;
         }
     }
     return true;
 }
Example #2
0
 /**
  * Tests whether this set is a subset of the specified set.
  * It is assumed that the specified set is an instance of
  * the SetAsArray class.
  *
  * @param object ISet $set The set to compare with this set.
  * @return boolean True if the this set is a subset of the specified set;
  * false otherwise.
  */
 public function isSubset(ISet $set)
 {
     if ($this->getClass() != $set->getClass()) {
         throw new TypeError();
     }
     if ($this->universeSize != $set->universeSize) {
         throw new ArgumentError();
     }
     for ($item = 0; $item < $this->universeSize; ++$item) {
         if ($this->array[$item] && !$set->array[$item]) {
             return false;
         }
     }
     return true;
 }