61 lines
1.6 KiB
Java
61 lines
1.6 KiB
Java
package uebung09.collection;
|
|
|
|
/**
|
|
* A set of elements that does not contain any element twice.
|
|
*
|
|
* @param <E> the type of all contained elements.
|
|
*/
|
|
public interface Set<E> extends Iterable<E> {
|
|
/**
|
|
* Returns the number of elements stored in this set.
|
|
*
|
|
* @return the number of elements in this set
|
|
*/
|
|
int size();
|
|
|
|
/**
|
|
* Returns true if this set contains no elements.
|
|
*
|
|
* @return true if this set contains no elements
|
|
*/
|
|
boolean isEmpty();
|
|
|
|
/**
|
|
* Returns true if this set contains the specified element.
|
|
*
|
|
* @return true if this set contains the specified element.
|
|
*/
|
|
boolean contains(Object el);
|
|
|
|
/**
|
|
* Returns the union set of this set and the specified set.
|
|
*
|
|
* @param other a set
|
|
* @return the union set of this set and the specified set.
|
|
*/
|
|
Set<E> union(Set<E> other);
|
|
|
|
/**
|
|
* returns the set resulting from adding the specified element to this set.
|
|
*
|
|
* @param elem an element (must not be null)
|
|
* @return the set resulting from adding the specified element to this set.
|
|
*/
|
|
Set<E> add(E elem);
|
|
|
|
/**
|
|
* Returns the intersection of this set and the specified set.
|
|
*
|
|
* @param other a set
|
|
* @return the intersection of this set and the specified set.
|
|
*/
|
|
Set<E> intersection(Set<E> other);
|
|
|
|
/**
|
|
* Returns true if all elements of this set are contained in the specified set.
|
|
*
|
|
* @param other a set
|
|
* @return true if all elements of this set are contained in the specified set.
|
|
*/
|
|
boolean subsetOf(Set<?> other);
|
|
} |