Exemplo n.º 1
0
  public boolean equals(Object o) {
    if (o == this) return true;
    if (o == null) return false;

    if (o.getClass() == getClass()) {
      Set otherSet = (Set) o;

      if (getType() != otherSet.getType()) {
        return false;
      }
      return data.equals(otherSet.data);
    }

    return false;
  }
Exemplo n.º 2
0
  public ISet union(ISet other) {
    ShareableValuesHashSet newData;
    Iterator<IValue> setIterator;

    Set otherSet = (Set) other;

    if (otherSet.size() <= size()) {
      newData = new ShareableValuesHashSet(data);
      setIterator = otherSet.iterator();
    } else {
      newData = new ShareableValuesHashSet(otherSet.data);
      setIterator = iterator();
    }

    while (setIterator.hasNext()) {
      newData.add(setIterator.next());
    }

    Type newElementType = elementType.lub(otherSet.elementType);
    return new SetWriter(newElementType, newData).done();
  }