Esempio n. 1
0
  @Override
  public boolean subset(Set<E> S) {
    if (setList.isEmpty()) {
      return true;
    }

    do {
      if (!S.setList.find(setList.retrieve())) {
        return false;
      }
    } while (setList.goToNext());

    return true;
  }
Esempio n. 2
0
  @Override
  public Set<E> intersection(Set<E> S) {
    Set<E> intersection = new Set<E>();
    if (!setList.goToFirst()) return intersection;
    if (S.setList.isEmpty()) return intersection;

    do {
      E el = setList.retrieve();
      if (S.setList.find(el)) {
        intersection.addElement(el);
      }
    } while (setList.goToNext());

    return intersection;
  }
Esempio n. 3
0
  @Override
  public Set<E> difference(Set<E> S) {
    if (!setList.goToFirst()) return this;
    if (S.isEmpty()) return this;

    Set<E> difference = new Set<E>();

    do {
      E el = setList.retrieve();
      if (!S.setList.find(el)) {
        difference.addElement(el);
      }
    } while (setList.goToNext());

    return difference;
  }
Esempio n. 4
0
  @Override
  public Table<K, V> clone() {
    Table copy;

    try {
      copy = (Table) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new Error("");
    }

    copy.table = new List<Mapping>();

    Mapping map;
    for (int i = 0; i < this.size(); i++) {
      map = table.retrieve();
      copy.addEntry(map.key, map.value);
      table.goToNext();
    }

    return copy;
  }