/**
  * Compares this set with another set for equality of their stored entries.
  *
  * @param other an <code>Object</code> value
  * @return true if the sets are identical
  */
 @Override
 public boolean equals(Object other) {
   if (_set.equals(other)) {
     return true; // comparing two trove sets
   } else if (other instanceof Set) {
     Set<?> that = (Set<?>) other;
     if (that.size() != _set.size()) {
       return false; // different sizes, no need to compare
     } else { // now we have to do it the hard way
       Iterator<?> it = that.iterator();
       for (int i = that.size(); i-- > 0; ) {
         Object val = it.next();
         if (val instanceof Character) {
           char v = ((Character) val).charValue();
           if (_set.contains(v)) {
             // match, ok to continue
           } else {
             return false; // no match: we're done
           }
         } else {
           return false; // different type in other set
         }
       }
       return true; // all entries match
     }
   } else {
     return false;
   }
 }
예제 #2
0
 public boolean equals(Object other) {
   if (!(other instanceof TCharSet)) {
     return false;
   }
   TCharSet that = (TCharSet) other;
   if (that.size() != size()) {
     return false;
   }
   for (int i = TCharShortHashMap.this._states.length; i-- > 0; ) {
     if ((TCharShortHashMap.this._states[i] == 1)
         && (!that.contains(TCharShortHashMap.this._set[i]))) {
       return false;
     }
   }
   return true;
 }
 @Override
 public boolean equals(Object other) {
   if (!(other instanceof TCharSet)) {
     return false;
   }
   final TCharSet that = (TCharSet) other;
   if (that.size() != this.size()) {
     return false;
   }
   for (int i = capacity(); i-- > 0; ) {
     if (_states.get(i) == FULL) {
       if (!that.contains(_set.get(i))) {
         return false;
       }
     }
   }
   return true;
 }
 /** {@inheritDoc} */
 @Override
 public boolean contains(Object o) {
   if (!(o instanceof Character)) return false;
   return _set.contains(((Character) o).charValue());
 }