Exemple #1
0
 /**
  * equal if obj is a bitset and contains the same bits as this
  *
  * @param obj Object
  * @return boolean
  */
 public boolean equals(Object obj) {
   boolean equalOk = false;
   if ((obj != null) && (obj instanceof NodeIdSet)) {
     NodeIdSet objBS = (NodeIdSet) obj;
     equalOk = (this.contains(objBS) && (this.cardinality() == objBS.cardinality()));
   }
   return equalOk;
 }
Exemple #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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());
 }