Beispiel #1
0
  @Override
  public E getRandom() {
    // long random = Math.round(Math.random() * setList.size());
    setList.goToFirst();

    // for(long i = 1; i < random; i++) {
    // setList.goToNext();
    // }

    return setList.retrieve();
  }
Beispiel #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;
  }
Beispiel #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;
  }