forked from erasmuss22/Music-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleSet.java
More file actions
89 lines (79 loc) · 2.12 KB
/
SimpleSet.java
File metadata and controls
89 lines (79 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Public interface to abstract data types representing sets of values.
* <p>
* <strong>Do not modify this file in any way!</strong>
*
* @author Ben Liblit
* @param <E>
* the type of data to be stored in this set
**/
public interface SimpleSet<E> extends Iterable<E> {
/**
* Adds the given item to this set if it is not already present.
*
* @param item
* reference to the item to be added
* @return true if the given item was added, false if it's already present
**/
public boolean add(E item);
/**
* Removes the given item from this set if it is present.
*
* @param item
* reference to the item to be removed
* @return true if the given item was removed, false otherwise
**/
public boolean remove(E item);
/**
* Determines if this set contains the given item.
*
* @param item
* reference to the item to be found
* @return true if the given item is in the set, false otherwise
**/
public boolean contains(E item);
/**
* Constructs a new set containing the items in this set and the given set
* but excluding duplicates.
*
* <p>
* Note: this operation does not change the original sets!
* </p>
*
* @param other
* the other set to unify with this set
*
* @return the new set containing the union
**/
public SimpleSet<E> union(SimpleSet<E> other);
/**
* Constructs a new set containing only the items that this set and the
* given set share in common.
*
* <p>
* Note: this operation does not change the original sets!
* </p>
*
* @param other
* the other set to intersect with this set
*
* @return the new set containing the intersection
**/
public SimpleSet<E> intersection(SimpleSet<E> other);
/**
* Removes all of the items from this set.
**/
public void clear();
/**
* Returns the size of this set, i.e., the number of items it contains.
*
* @return the number of items in this set
**/
public int size();
/**
* Determines if this set is empty, i.e., contains no items.
*
* @return true of the set is empty, false otherwise
**/
public boolean isEmpty();
}