Suppose that we want to implement the ADT set. Recall from Segment 1.21 of Chapter 1 that a set is an unordered collection of objects in which duplicates are not allowed. The operations that a set should support are
Add a given object to the set
Remove a given object from the
set See whether the set contains a given object
Clear all objects from the set
Get the number of objects in the set
Return an iterator to the set
Return a set that combines the items in two sets (the union)
Return a set of those items that occur in both of two sets (the intersection)
Augment the interface Set Interface, as given in Listing 1-5, to include these operations. Then define a class Dictionary Set that implements Set Interface and uses a dictionary internally to implement these operations.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here