"Congratulations on upgrading your skills. We need guys who are prepared to do anything."
"I'm sure you still have many unfinished tasks. It's time to finish some of them!"
AmigoSet (part 1)
Let's write some sort of collection. Let it be your very own Set. Let this class allow null values to be added. 1. Create an AmigoSet class. Let this class inherit AbstractSet. The set must support the Serializable and Cloneable interfaces (how could it not??). It's also obvious that it must imple
AmigoSet (part 2)
We won't re-invent the mechanism for working with hashes — It has already been implemented in lots of collections. We'll grab HashMap and use it. 1. Create a private Object PRESENT constant and initialize it with an Object. This will be our stub. 2. Create a private transient HashMap
AmigoSet (part 3)
Write your own implementation of the following methods that allow you to work with the keys in map: * Iterator
iterator () - Obviously, this is a key iterator. Get the set of keys in map, and return its iterator
* int size() - This is the number of keys in map. It is equal to the number of eleme
AmigoSet (part 4)
Your AmigoSet set implements the Cloneable interface. However, it doesn't clone properly. Write your own implementation of the Object clone() method, so that it creates a shallow clone. * Clone the set, and clone map. * Throw an InternalError if an exception occurs. * Eliminate the throwing of oth
AmigoSet (part 5)
Your AmigoSet set implements the Serializable interface. However, it doesn't serialize properly. 1. Implement your own logic for serializing and deserializing. Remember which private methods you need to add in order to serialize correctly. To serialize: * serialize the set * serialize the map obje
AmigoSet (part 6)
Open the HashSet's source (if you don't have the Java source, download it, and connect it), and compare it to your code. You can do this quickly by comparing with the clipboard. Copy the HashSet class's source code to the clipboard. Go to the AmigoSet class, and then right-click -> Compare with Cli