Пример #1
0
  /** {@inheritDoc} */
  @Override
  public boolean equals(final Object obj) {
    if (obj != null) {
      if (obj == this) {
        return true;
      }

      // must be of the same class, subclasses are not comparable
      if (obj.getClass() != this.getClass()) {

        return false;
      }

      @SuppressWarnings("unchecked")
      final KTypeSet<KType> other = (KTypeSet<KType>) obj;

      // must be of the same size
      if (other.size() != this.size()) {
        return false;
      }

      final EntryIterator it = this.iterator();

      while (it.hasNext()) {
        if (!other.contains(it.next().value)) {
          // recycle
          it.release();
          return false;
        }
      }
      return true;
    }
    return false;
  }