Exemple #1
0
 /**
  * modify this bitset by removing anything that is in s (logically bitwise: this = this AND ( NOT
  * s)) return true if any modification, otherwise false
  *
  * @param s BitSet
  * @return BitSet
  */
 public boolean subtract(NodeIdSet s) {
   boolean subOk = false;
   byte[] test = s.getBytes();
   int minLength = ((storage.length < test.length) ? storage.length : test.length);
   byte oldValue = 0;
   for (int i = 0; i < minLength; ++i) {
     oldValue = storage[i];
     storage[i] &= ~test[i];
     if (storage[i] != oldValue) subOk = true;
   }
   return subOk;
 }
Exemple #2
0
 /**
  * modify this bitset by removing anything that is NOT also in s (logically bitwise: this = this
  * AND s) return true if any modification, otherwise false
  *
  * @param s BitSet
  * @return boolean
  */
 public boolean removeComplement(NodeIdSet s) {
   boolean rcOk = false;
   byte[] test = s.getBytes();
   int minLength = ((storage.length < test.length) ? storage.length : test.length);
   byte oldValue = 0;
   for (int i = 0; i < minLength; ++i) {
     oldValue = storage[i];
     storage[i] &= test[i];
     if (storage[i] != oldValue) rcOk = true;
   }
   return rcOk;
 }
Exemple #3
0
 /**
  * are there any bits in both this and s?
  *
  * @param s BitSet
  * @return boolean
  */
 public boolean overlap(NodeIdSet s) {
   boolean overlapOk = false;
   byte[] test = s.getBytes();
   int minLength = ((storage.length < test.length) ? storage.length : test.length);
   for (int i = 0; i < minLength; ++i) {
     if ((storage[i] & test[i]) != 0) {
       overlapOk = true;
       break;
     }
   }
   return overlapOk;
 }
Exemple #4
0
 /**
  * modify this bitset by adding all the bits that are in s (logically bitwise: this = this OR s)
  * return true if any modification, otherwise false
  *
  * @param s BitSet
  * @return BitSet
  */
 public boolean merge(NodeIdSet s) {
   boolean mergeOk = false;
   int msb = s.getMaxBitPos();
   if (msb > this.size()) storage = createByteArray(msb, storage);
   byte[] test = s.getBytes();
   byte oldValue = 0;
   for (int i = 0; i < storage.length; ++i) {
     oldValue = storage[i];
     storage[i] |= test[i];
     if (storage[i] != oldValue) mergeOk = true;
   }
   return mergeOk;
 }
Exemple #5
0
 /**
  * Return a new identical copy
  *
  * @return BitSet
  */
 public Object clone() {
   NodeIdSet cloneBS = new NodeIdSet(this.size());
   byte[] cloneStorage = cloneBS.getBytes();
   for (int i = 0; i < storage.length; ++i) cloneStorage[i] = storage[i];
   return cloneBS;
 }
Exemple #6
0
 /**
  * are all the bits in this contained in s?
  *
  * @param s BitSet
  * @return boolean
  */
 public boolean containedIn(NodeIdSet s) {
   return compare(s.getBytes(), storage);
 }
Exemple #7
0
 /**
  * Are all the bits in s contained in this?
  *
  * @param s BitSet
  * @return boolean
  */
 public boolean contains(NodeIdSet s) {
   return compare(storage, s.getBytes());
 }