1: /**
2: An interface that describes the operations of a set of objects.
3:
4: @author Charles Hoot, Frank M. Carrano
5: @version 4.0
6: */
7: public interface SetInterface<T>
8: {
9: /** Gets the current number of entries in this set.
10: @return The integer number of entries currently in the set. */
11: public int getCurrentSize();
12:
13: /** Sees whether this set is empty.
14: @return True if the set is empty, or false if not. */
15: public boolean isEmpty();
16:
17: /** Adds a new entry to this set, avoiding duplicates.
18: @param newEntry The object to be added as a new entry.
19: @return True if the addition is successful, or
20: false if the item already is in the set. */
21: public boolean add(T newEntry);
22:
23: /** Removes a specific entry from this set, if possible.
24: @param anEntry The entry to be removed.
25: @return True if the removal was successful, or false if not. */
26: public boolean remove(T anEntry);
27:
28: /** Removes one unspecified entry from this set, if possible.
29: @return Either the removed entry, if the removal was successful,
30: or null. */
31: public T remove();
32:
33: /** Removes all entries from this set. */
34: public void clear();
35:
36: /** Tests whether this set contains a given entry.
37: @param anEntry The entry to locate.
38: @return True if the set contains anEntry, or false if not .*/
39: public boolean contains(T anEntry);
40:
41: /** Retrieves all entries that are in this set.
42: @return A newly allocated array of all the entries in the set. */
43: public T[] toArray();
44: } // end SetInterface